View previous topic :: View next topic |
Author |
Message |
mforkner
Joined: 04 Aug 2004 Posts: 78
|
Posted: Fri Nov 12, 2004 1:27 pm Post subject: Setting Focus |
|
|
Hi,
I have hit a snag in setting the focus of an object on a windows form. I did search Help & Component Tray, but can't find a topic on this subject. Please excuse me if it is there.
I would like to know how to set focus on a particular button or text input box, etc..
Thank you,
Michael Forkner |
|
Back to top |
|
|
CodeMorphis
Joined: 02 Dec 2003 Posts: 252
|
Posted: Fri Nov 12, 2004 4:11 pm Post subject: |
|
|
Michael,
The functionality you seek is served by the "Set focus" service of the "UI Component Interface" found in the Windows tab of the Component Tray.
To use the service, simply select the target UI component and the Windows form that contains it.
The "Set focus" command was added as part of Update 1.1.1 which is why it currently is only found in the "UI Component Interface" component - the UI Component Interface controls properties common to all UI components. Eventually the "Set focus" service will appear in every UI interface component.
Hope that this helps. |
|
Back to top |
|
|
michaelforkner
Joined: 04 Aug 2004 Posts: 12
|
Posted: Fri Nov 12, 2004 6:41 pm Post subject: Set Focus |
|
|
Hello,
Yes, I did find that service. Thank you. I zipped right past it last night while looking. Sorry. However, perhaps I'm using the wrong terminology. I want to make the cursor be in the textbox of my choosing, or have a button selected as a default of my choosing. I have tried to do this using the set focus of the UI Interface component, but to no avail. Perhaps you could reply with a proper method ( no need for screen shots ), or correct me as to how the set focus actually works with a windows form.
Thank you,
Michael Forkner |
|
Back to top |
|
|
CodeMorphis
Joined: 02 Dec 2003 Posts: 252
|
Posted: Fri Nov 12, 2004 8:33 pm Post subject: |
|
|
That is the correct service to use.
The Windows form needs to be displayed when calling the service so that the visual update can be effected.
Here is a simple program example that demonstrates how to set focus to a textbox:
Note the edit cursor that appears in the textbox. You can see that the "Set focus" service is selected on the UI Component interface. The arguments of the input data ports of the component specify the Windows form and the textbox UI component.
Here is the link to the above program:
http://www.codemorphis.com/articles/ans_111204/focus.vpd
Try selecting one of the buttons for the argument of input data port 1 of the UI Interface component to see how to set focus to the button.
Another thing you might want to experiment with is placing the UI Interface component inside the windows event loop:
If you run the program you can click somewhere in the window not occupied by a UI component, for instance, and for each mouse click the set focus service will be called. Before each click you make, try changing the UI component argument in input data port 1 of the UI Interface. You will see the focus change to your selected UI component.
This is another example of experimenting with your program in real-time without the need to stop your program. In a traditional development approach, for each experimentation change you would have to exit the program, return to the IDE to make changes and then re-run the program. With Synopsis, you can avoid all of this waterfall development approach and get instant feedback!
Here is the link to the modified program:
http://www.codemorphis.com/articles/ans_111204/focus2.vpd
Please don't hesitate to ask if you need further explanations. |
|
Back to top |
|
|
michaelforkner
Joined: 04 Aug 2004 Posts: 12
|
Posted: Fri Nov 12, 2004 11:35 pm Post subject: Thank You |
|
|
I sure wasn't expecting the screen shots and vpd's , so thank you very much. This was exactly what I was trying to do.
Regards,
Michael Forkner |
|
Back to top |
|
|
|