[Gambas-user] RE:[Gambas-user] Question re control groups
jcostello at ...903...
jcostello at ...903...
Wed Mar 23 23:32:40 CET 2005
Eldon,
You can write a handler for each button in the group. I have done them for processes writing a handler for each one.
The trick is with the sentence Object.Attach. Here I copy what the help says:
(FROM SHELL TOPIC in Gambas Help)
"Differences from VB
Unlike the VB Shell command, which returns a process ID and relies on the programmer to make API calls to control the process, the Gambas Shell function optionally returns a Process object (if called with the AS parameter) which can be used to directly kill or otherwise control the spawned process. Additionally, the process may be run synchronously or asynchronously, in contrast to the VB equivalent.
Tip: You may have noticed that all Process events fire the same event handlers, namely Process_Read, Process_Kill, etc. You can differentiate between processes in two ways: Make each Process object global to your class and go "IF LAST.Id = Process1.Id THEN..."
Use Object.Attach to redirect its events to a different set of handlers "
I recommend the last option.
I believe that writing the name of the control plus the "_" plus the event name would do it.
For example:
say the button is named "Button1".
Inside the help appear the following events:
Click DblClick Drag DragMove Drop Enter GotFocus KeyPress KeyRelease Leave LostFocus Menu MouseDown MouseMove MouseUp MouseWheel
and, if you want to write to change the Text property when the user clicks the button then the sub can be:
PUBLIC SUB Button1_Click()
Button1.Text = "Hi, I have changed"
...
...
...
here goes all the code you want
...
...
END
Of course, I have done it with an event of the same control, but as you know you can do it with events from another controls, it is limited by your imagination.
I hope this was useful.
Any doubt please tell me.
Cheers.
Juan
__________________________________________________
Datafull - 100% Internet Gratis
http://www.datafull.com
More information about the User
mailing list