Help with button - want to incorporate a visual cue

ok, my last question today, i promise :slight_smile:

i'm working out a way to imitate the middle-click 'sticky selection' in Opus without sacrificing the current functionality of my middle mouse button.

so far, the best way i have found to do this is with NirCmd's 'sendkey' function - i left-click a button to send Windows a message that the CTRL key is being held, then i right-click the button to send a message that the CTRL key is released. it works like a charm.

unfortunately, with a 3-way button like i have used, i can't see any way to make a visual cue so that i know what the state of the function is.

is there a better way than a 3-way button to implement something like this? i'm thinking something along the lines of Prefs STYLELIST which has different 'buttons' for different states, and you can easily see which one is selected. but i don't believe there is a way to replicate this...

any suggestions would be appreciated!

here is the button code as it stands right now:

<?xml version="1.0"?> <button backcol="none" display="icon" popout="right" textcol="none" type="three_button"> <label>New Button</label> <icon1>C:\Program Files\Directory Opus\Ico\Dots Down.ico</icon1> <icon2>C:\Program Files\Directory Opus\Ico2\Dots Down.ico</icon2> <button backcol="none" display="both" textcol="none"> <label>Sticky selection ON</label> <icon1>C:\Program Files\Directory Opus\Ico\Dots Down.ico,0</icon1> <function type="normal"> <instruction>C:\Program Files\NirCmd\nircmd.exe sendkey ctrl down</instruction> </function> </button> <button backcol="none" display="label" textcol="none"> <label>Sticky selection OFF</label> <icon1>C:\Program Files\Directory Opus\Ico\Dots Down.ico,0</icon1> <function type="normal"> <instruction>C:\Program Files\NirCmd\nircmd.exe sendkey ctrl up</instruction> </function> </button> </button>

Since you're toggling the Ctrl key with the button you can use the @keydown feature to make a single button that acts as a toggle, if you want:

[code]@keydown:none
"C:\Program Files\NirCmd\nircmd.exe" sendkey ctrl down

@keydown:ctrl
"C:\Program Files\NirCmd\nircmd.exe" sendkey ctrl up[/code]

I can't think of a good way to make it indicate which mode is active. I can think of a bad way though. :slight_smile:

Find some option in Opus which can be toggled via the Set command and which you don't care about the state of. SOUNDS is a good one for me since I don't have any sounds configured in Opus and the program is silent whether the overall "Enable Sounds" option is on or off.

Now make a button like this:

[code]Set SOUNDS=Toggle

@keydown:none
"C:\Program Files\NirCmd\nircmd.exe" sendkey ctrl down
Set SOUNDS=On

@keydown:ctrl
"C:\Program Files\NirCmd\nircmd.exe" sendkey ctrl up
Set SOUNDS=Off[/code]

That button will now toggle the Ctrl key up and down, and will change between normal and pushed-in each time you click it.

It's not perfect. Since the SOUNDS option isn't really dependent on the Ctrl key being up or down it's possible for the button's appearance to be out of sync with the Ctrl key. Clicking on the button will fix that whenever it happens.

thanks leo! the 'bad way' is just ideal, it works wonderfully for my purposes and i don't anticipate any problems with the sounds setting.

also, that @keydown feature seems useful, i'm sure it will come in handy as i labour to perfect my configuration. i need to read a bit deeper into the manual, i missed that on my first run :slight_smile:

thanks again!