Problem with actions on buttons

Q&A about the latest versions
Post Reply
LINK3D
Posts: 16
Joined: Mon Nov 25, 2019 5:53 pm

Hello,

I want to have one button in my project that changes the view state from 0 to 1 and vice versa. And then that an other button appears in view state 1 that changes the view state between 1 and 2 and vice versa.

At the moment the button just works one time, changing the View state from 0 to 1. Then clicking it doesn't change anything.

I have two actions on my first button :

mouse up -> set view state to 1 with execute action if view state is 0
mouse up -> set view state to 0 with execute action if view state is 1

But it works only once (if I start in view state 0, it switches to 1; if I start in view state 1 it switches to 0).
User avatar
Hopki
Gnome
Posts: 13536
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Hi,
You need separate variables, please see the attached project.
Text box 1 toggle states 1 & 2
Text box 2 toggled states 2 & 3
While state 3 is visible you can not select text box 1
Regards,
Attachments
project.zip
(500.81 KiB) Downloaded 164 times
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
LINK3D
Posts: 16
Joined: Mon Nov 25, 2019 5:53 pm

Thanks that worked perfectly.

But now I got a problem building from this.

Now I got 4 Images I want to toggle on and off.
I created 4 Variables (vis_a, vis_b, vis_c, vis_d).
As well as 4 Buttons (A, B, C, D).
When I click Button A, Image A should appear and if any of the other images are visible these should disappear.
Each of my Buttons has the following actions (here button A)
1. Mouse Click -> set variable value vis_A= true
2. Variable Changed vis_A -> set variable value vis_B=false
3. Variable Changed vis_A -> set variable value vis_C=false
4. Variable Changed vis_A -> set variable value vis_D=false

Now if Variable A is true, the first click on Button B changes it's value to false (so all variables are now false), and the second click on B changes the var_B to true...
I would like it to be one click only, and I don't understand why it's not.....
User avatar
Hopki
Gnome
Posts: 13536
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Hi,
I find using a numbered variable is excellent when you want to open and close one element at a time.
For example 0, would be to hide everything.
Then 1, would open one image, 2 a different image.
As the image visible attribute is using the variable, when the correct number is selected then it will show.
Of course, as soon as the number changes, it will hide without any other actions.

The button would have a Mouse Click source action, then the action will be Set Variable Value, changing the number.

I have put together a little project that uses the numbered variable to display four images.
As well as having a separate button for each button, there is number up and down buttons to scroll through the images.
This requires a little more work, but you only have to set up one button, then copy and paste the actions to the other button only changing the set variable value action.
Regards,
Attachments
project.zip
(284.31 KiB) Downloaded 173 times
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
Post Reply