Using the same click event
Posted
#1
(In Topic #1129)
Trainee
If you have an entry in the file menu, for example Menu_File_OpenFile and you also have a button the form, for example BtnOpenFile, they will have their own click events even though they will do the same thing. I know that you could call the same routine from within those events but it would save some code if both shared the same click event. Is this possible?
Thanks
Pusherman
Posted
Guru

if the Group property is set the event will be of the Group name
So if you set both the menu and the button to be group MyFunctions
they will both trigger..
You can tell what was pressed using the Last keyword.
You can also make many buttons/menus use the same event
For example below i set many buttons/menus to a single Group/Functions event…
For the example i have a menu named mnuBegin and button named btnBegin , both Group is MyFunctions
It's most likely you will not need to know if it's the menu or button and just run the function.
also it is easy if you are creating buttons/menu's via code as you can give them the same name.
eg..
Code (gambas)
- m.Text = "Begin"
- m.Name = "Begin"
- b.Text = "Begin"
- b.Name = "Begin"
- Case "Begin"
Posted
Trainee
When I look in the Group property (where your arrow is indicating) I get a drop down box with nothing in it. I can't manually edit that property.
How do you create the group that goes into that property field?
Pusherman
Posted
Guru

pusherman said
Thanks for replying.
When I look in the Group property (where your arrow is indicating) I get a drop down box with nothing in it. I can't manually edit that property.
How do you create the group that goes into that property field?
Pusherman
I think it's a bug in the IDE/GTK Toolkit
Just click the Group box and type a name and then press return
then click another property and you will see the text appear in the Group box
It works but you cannot see the text as you type
or run the IDE with QT as i think it's only a gtk problem
$ env GB_GUI=gb.qt5 gambas3
Posted
Trainee
Thanks for your time
Posted
Guru

Code
# Gambas Form File 3.0
\{ Form Form
MoveScaled(0,0,105,55)
\{ Button1 Button
MoveScaled(40,13,16,4)
}
\{ Button2 Button
MoveScaled(40,25,16,4)
}
}If you edit the file introducing a Group called MyGroup like this: -
Code
# Gambas Form File 3.0
\{ Form Form
MoveScaled(0,0,105,55)
\{ Button1 Button MyGroup
MoveScaled(40,13,16,4)
}
\{ Button2 Button MyGroup
MoveScaled(40,25,16,4)
}
}If you now open the IDE and look at the Group property for both buttons, you will see that the property is now populated.
Posted
Trainee
Sometimes it works and others not. Doing it manually like you suggest is another work-around.
1 guest and 0 members have just viewed this.




