WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-29-2008, 09:32 AM
Uttama_vizard Uttama_vizard is offline
Member
 
Join Date: Sep 2007
Posts: 60
Deactivating Particular keys

Hello,

Is there any way to deactivate any particular key of the keyboard? For mouse, it is there.

Thanks

Uttama
Reply With Quote
  #2  
Old 07-29-2008, 11:28 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I'm not sure exactly what you mean. Can you explain what you are trying to do?
Reply With Quote
  #3  
Old 07-31-2008, 07:09 AM
Uttama_vizard Uttama_vizard is offline
Member
 
Join Date: Sep 2007
Posts: 60
Hello,

Actually, I am developing an interactive gave using vizard. In this, a subject has to interact with the game using keys. I want to restrict the number of keys used. So, sometimes, my same key performs different actions in different parts of the interactive game. Say, a 'd' key means Enter at one time and again at another time, 'd' key is to be disregarded, that is it should not activate the Enter function.

In that case, I was trying to deactivate the 'd' key at a later instant, so that even if the subject presses the 'd' key, the Enter function is not activated.

For mouse, there is the Override function...actually I was looking for such a function for keys of the keyboard or keys of an external handheld keyboard.

Thanks

Uttama
Reply With Quote
  #4  
Old 07-31-2008, 11:40 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Depending on how you are handling the different key callbacks, you can unregister the specified key callback when you want it to be deactivated. Then simply register the callback again when you want the key activated. How are you handling the key presses, are you using the vizact.onkeydown functions or the viz.callback functions?
Reply With Quote
  #5  
Old 08-01-2008, 10:36 AM
Uttama_vizard Uttama_vizard is offline
Member
 
Join Date: Sep 2007
Posts: 60
Hello,

I am using both. At one point of time, I am using viz.callback and another time, I am using onKeyDown function.

Registering key callback....what you suggested is not clear to me. Can you please elaborate a little bit more?

Thanks

Uttama
Reply With Quote
  #6  
Old 08-01-2008, 11:10 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is some sample code showing how to switch between 2 different keydown callback functions. You can press the 1,2 keys to set which callback to use. Pressing spacebar will print out which callback is currently registered.
Code:
import viz
viz.go()

def onKeyDown1(key):
	
	if key == '2':
		viz.callback(viz.KEYDOWN_EVENT,onKeyDown2)
	
	elif key == ' ':
		print 'space pressed in callback 1'
		
def onKeyDown2(key):
	
	if key == '1':
		viz.callback(viz.KEYDOWN_EVENT,onKeyDown1)
	
	elif key == ' ':
		print 'space pressed in callback 2'

viz.callback(viz.KEYDOWN_EVENT,onKeyDown1)
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 05:13 AM.


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