Archive: NSD_OnClick not supported by NSD_CreateText: Bug or By Design?


NSD_OnClick not supported by NSD_CreateText: Bug or By Design?
Hey guys,
I tried to use {NSD_OnClick} with a Text Box: {NSD_CreateText}, but it's not supported. If I use {NSD_OnChange}, it works without a problem.

Basically, I want to clear the default text I have in the text box as soon as the user clicks it.

Is this a bug or not added by design?


I don't think edit controls respond to a click, typically. There is one work-around, but you may not like it very much - but I've had to use it for a different reason* and it works fine.

1. start a timer when your page displays
2. in the timer's callback function, use..

System::Call "user32::GetFocus(v) i.r0"

..to get the hwnd of the control that currently has focus.
3. compare that hwnd to the previous hwnd (so you'll need to store that in a temporary variable somewhere).
4.1 IF the previous hwnd was NOT your edit control (Pop'd after our create it, so pop that to a variable as well).
4.2 AND IF the current hwnd IS your edit control
5. Use ${NSD_SetText} YourTexthwnd "" to clear your edit control's content.

You can easily set the timer to run every, say, 250ms and users will typically not notice that it's a delayed action; otherwise, drop down to 100ms.. doesn't hurt as bad as you might think.

* The way I use this is to test a value entered in an Edit control only -after- the control loses focus, instead of every OnChange (the test can take a few seconds to run, which is annoying if it happens for every letter changed). I start a timer using an OnChange callback, which I later kill when focus is removed from the Edit control (so that it is not running unnecessarily).