Apply 'entry':u

Posted by GregHiggins on 07-Jan-2009 10:39

How do I apply entry to a NUI component? I have a text-box that I am filling from a button press; I want focus in the textbox after the button is pressed.

All Replies

Posted by Peter Judge on 07-Jan-2009 10:48

How do I apply entry to a NUI component? I have a

text-box that I am filling from a button press; I

want focus in the textbox after the button is pressed.

txtBox:Focus().

-- peter

Posted by GregHiggins on 07-Jan-2009 11:07

OK, I think I've got it now.

Readonly logical property Focused tells if the control has focus.

Void method Focus gives it focus.

Events GotFocus and LostFocus apply as focus is given or taken away.

Posted by Admin on 07-Jan-2009 11:35

Just in case you'd ever just want to raise the event (without actually applying focus to the control), you can execute the OnGotFocus() method of the Control.

Pretty handy if you want to call the event handlers (subscribers) without caring if they are available or not. I've used if a couple of times for TextChanged or Resized event handlers.

Posted by GregHiggins on 07-Jan-2009 11:44

Which is the code I would have installed in the myTextBox_OnGotFocus method of myform.cls.

Posted by Admin on 07-Jan-2009 11:55

Wouldn't that result in an endless lopp? Basically the OnGotFocus() method should execute the myTextBox_OnGotFocus event handler (and other event handlers, as a .NET Control can have more than one subscriber for the same event).

Posted by GregHiggins on 07-Jan-2009 14:56

Now I'm confused; isn't the myTextbox_OnGotFocus method of myForm.cls the event handler? If not, why amd I writing it to handle the onGotFocus event?

Posted by Admin on 08-Jan-2009 02:08

It's one of the event handlers.

.NET Controls can have any number of event handlers per event. So myTextbox_OnGotFocus (sender, e) might be an event handler. You could add another one (when done in the Visual Designer, this needs to be coded manually). That event mechanism is similar to PUBLISH and SUBSCRIBE with procedures.

And myTextBox:OnGotFocus is similar to

PUBLISH OnGotFocus (myTextBox, NEW System.EventArgs()) FROM myTextBox.

All Subscribers will receive that notification (one after the other).

Message was edited by:

Mike Fechner

Posted by GregHiggins on 08-Jan-2009 11:04

As I'm understanding you, in the code below, not only could I replace openDialog:FileOk:subscribe ( this-object:openDialog_FileOk )

with a completely different method name, i.e., openDialog:FileOk:subscribe ( this-object:FileOK_openDialog )**,

I could also subscribe a method in another object: openDialog:FileOk:subscribe ( someOtherObject:someMethod )**

or,

having the openDialog instance variable defined in some other procedure or class,

I could subscribe a method from any available class which acts either when the event was fired naturally,

or

which acts when I simulate the event by calling openDialog:OnFileOK ( ) with the appropriate parameter

,

at which point all subscribed eventhandlers will be called.

    • providing the appropriate method is correctly defined

Posted by Admin on 08-Jan-2009 13:56

Absolutely correct.

And the event handler can also be in a procedure. Then the arguments for the Subscribe method are the quoted internal procedure name and the persistent procedure handle.

In that case the procedure requires the sender and EventArgs input parameter... The validity of the parameters is evaluated at runtime, not at compiletime.

Posted by GregHiggins on 08-Jan-2009 15:59

Great. I wasn't sure about that last part, but once you mentioned it I check every reference to subscribe in the manuals and sure enough, it's documented.

This thread is closed