WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-21-2007, 05:35 PM
cade_mccall cade_mccall is offline
Member
 
Join Date: Sep 2004
Posts: 61
button problems

Hi-

I'm working with GUIs and I have a problem when I add both a textbox and a button. When I run the script below, I click on the textbox and, as expected, that triggers an event. The weird thing is, when I click on the button, it triggers another event for the textbox (<viz.VizTextbox object at 0x01FFF6F0>). It's not until the second time I click the button that I get an event for the button (<viz.VizCheckBox object at 0x01FFFE50>).

button = viz.addButton()
button.translate( .5, .5 )
text = viz.addTextbox()
text.translate( .5, .8 )
def onButton(obj,state):
print obj
if obj == button:
print 'now accepting buttons'
viz.callback(viz.BUTTON_EVENT,onButton)
Reply With Quote
  #2  
Old 02-21-2007, 06:31 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You need to check the state flag that is being sent to your callback. When a textbox gains focus it will generate a button event with a DOWN state. To remove focus from a textbox you need to either press escape, enter, or click outside the textbox. When this happens another button event will be triggered, but in the UP state. While the textbox has focus, clicking other GUI items won't do anything.
Reply With Quote
  #3  
Old 02-21-2007, 09:24 PM
cade_mccall cade_mccall is offline
Member
 
Join Date: Sep 2004
Posts: 61
damn you're fast
Reply With Quote
  #4  
Old 02-22-2007, 10:48 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
It's because WorldViz makes me wear a device that gives me an electric shock every time somebody posts on the forum.

Please make it stop
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:20 AM.


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