WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   button events when drawing over gui elements (https://forum.worldviz.com/showthread.php?t=1955)

moooh 04-08-2009 09:43 AM

button events when drawing over gui elements
 
I have a quad that I'm drawing that acts as sort of like an info screen that can be shown/hidden by pressing a key. The quad contains several different areas that can be clicked and the chosen area is determined in a mousedown event.

Part of this quad, when visible, overlaps a vizinfo menu that contains buttons. I've made sure that the quad is drawn over the menu, however, when clicking at the spots that overlap the vizinfo buttons, the button events are fired instead and the mousedown event is skipped completely. This has probably something to do with GUI elements like buttons being considered always in front when clicking.

The drawOrder of the elements does not seem to affect which event is fired.
I have tried switching around priorities for the menu onButton event and the mousedown event callbacks but that didn't help either.

One workaround would be to disable the buttons in the menu when the quad is visible, however the buttons are not easily accessible from the part of the code that deals with opening and closing this infowindow.
Just wanted to ask if there's some way to make the mousedown event have the same internal priority that the GUI components seem to enjoy.

Jeff 04-09-2009 01:03 PM

In your case the mouse button event is not being passed on. Would it work to send a mouse event when the button event occurs?
Code:

import viz
viz.go()

import vizinfo
infoObject = vizinfo.add('Give me feedback!')
button = infoObject.add(viz.BUTTON, 'Push me')

def onMouse():
        pos = viz.mouse.getPosition()
        print 'mouse is currently at',pos
       
vizact.onmousedown(viz.MOUSEBUTTON_LEFT, onMouse)

def onButton(obj,state):
        if state == viz.ON:
                viz.sendEvent( viz.MOUSEDOWN_EVENT, viz.MOUSEBUTTON_LEFT )

viz.callback(viz.BUTTON_EVENT,onButton)


moooh 04-10-2009 01:01 AM

Good call. If we can't prevent the button event from running I guess the second best thing is to make sure both events are run instead.
I can easily make sure that the onbutton does nothing except passing on the mouse event when the infobox is open, so this will definitely work. Thanks!


All times are GMT -7. The time now is 05:46 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC