Topic: Buttons and Evars with nModules

Hi I've managed to update a lot of my themes to the new nModules but I'm having trouble converting a line of code.

ButtonOnLeftClick         !ParseEvars !ParseEvars %#%[exportedevar('ButtonCurrentState')]%OnLeftClick%#

where it'd switch between two values for ButtonCurrentState

ButtonState1OnLeftClick "!execute [!setevar ButtonCurrentState ButtonState2]"

ButtonState2OnLeftClick "!execute [!setevar ButtonCurrentState ButtonState1]"

Basically I need to know how that'd look with nTheme coding, because I've looked through the Docs, and so far I'm stumped.


Re: Buttons and Evars with nModules

Not fully certain if I can follow what's going on there. Are ButtonState1/2 also nlabels or other n-objects? If so, it's pretty much:

*ButtonOn LeftClickUp  none  !ParseEvars %#%[exportedevar('ButtonCurrentState')]%OnLeftClick%#
;(^ Did you have two !ParseEvars on this on purpose? If so, add the other one back in)

*ButtonState1On LeftClickUp  none  !execute [!setevar ButtonCurrentState ButtonState2]

*ButtonState2On LeftClickUp  none  !execute [!setevar ButtonCurrentState ButtonState1]

Not sure if you really need the !execute[] either, as you're firing only one bang.

And the docs do have it explained, just in a somewhat unintuitive place tongue
Applies to every nmodule, not just nDesk.


Re: Buttons and Evars with nModules

It's a theme by someone else and I'm updating it there are more bangs associated with the !Execute but they're bangs I figured out how to do.

Basically what the two button states are evar values that the "buttoncurrentstate" evar switches between.

That could be enough to get it working though thanks I wasn't sure if the set Evar bangs still worked


Re: Buttons and Evars with nModules

Okay I figured out a workaround since the original creator did it a bit strangely, basically what I want to make is a toggle button, you click it once it shows stuff and another click hides them again without having to make two labels. I figured the solution is an "if statement" I used !Minimize/restore windows as a test bang but it seems to not work for some reason. It either wont change the evar or it isn't detected in the if statement. Here's the code.

  if ButtonShow1 = true
    *ButtonShowOn LeftClickUp none !execute [!RestoreWindows][!setevar ButtonShow1 false][!ParseEvars]

  elseif ButtonShow1 = false
    *ButtonShowOn LeftClickUp none !execute [!MinimizeWindows][!setevar ButtonShow1 true][!ParseEvars]


I changed the values manually in themeevars.rc and they both work what did I do wrong? I've been struggling with toggle-buttons since I started using Litestep and I'm still stumped.