DirectButton

In the DirectButton API you can assign commandButtons as either LMB, MMB or RMB. Haven’t played around with altering the widgets that much but is there a way to assign a particular command to a particular mouse button? For instance I want right click to do something different than a left mouse click.

Open to suggestions if any would mind pointing me in the right direction.

** Edited NM, I think I found the issue just searched for the wrong thing. Assuming (will check later tonight) that I can just use something like button1.bind(DGG.B3PRESS, leftClickMethod) and button1.bind(DGG.B1PRESS, rightClickMethod) ?

Not sure to understand what you want to do!
When the user press a desired mouse button or keyboard presset, an event is generated. It’s up to you to link the event to any function
It’s well explained here

What I meant was this …

Typically your DirectButtons are setup as follows:

self.btn1 = DirectButton(geom=(1,2,3,4),
            relief=None,
            command=something,
            extraArgs=[something else])

Within the API it tells you that you can set the commandButtons to RMB, MMB or LMB. I needed my buttons to react to events from both the RMB and LMB, which would also mean the DirectButton would have to have logic builtin to the class to allow for me to point the specific button events to a specific command.

What I ended up doing was finding a post by accident that illustrated how to use .bind(DGG.event, method) with direct gui widgets (all though I found out last night it doesn’t work for onscreen images … pity really).

self.btn1 = DirectButton(geom=(1,2,3,4),
            relief=None)
self.btn1.bind(DGG.B1PRESS, something, extraArgs=[something1])
self.btn1.bind(DGG.B3PRESS, something2, extraArgs=[something2])

So I can still see the rollover geom, change the state to disabled and see the disabled geom, see the text when I hover over it and hear whatever sound I want to hear.

Not sure if it’s right but it works and best of all, it was easy.

P.S. I know I don’t say the right things when it comes to coding for the most part, with very rare exceptions. Appreciate the response though!

If there is a better way to do this, I am all ears but that code is pretty efficient so I don’t know if I would abandon it unless it makes the project unstable or the DirectButton really has this method builtin and it’s just not in the API.

Edited to add: not trying to be ungrateful with your response, really do appreciate any and all help. I just don’t ask the right questions the right way most of the time.

That is the correct way to do it. And for the record, although it doesn’t work for an OnscreenImage, it does work for a DirectLabel, if you set state = DGG.NORMAL in the constructor.

David