WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Question about input from virtual keyboard. (https://forum.worldviz.com/showthread.php?t=1763)

yyang 12-18-2008 09:57 PM

Question about input from virtual keyboard.
 
Hi, I run into a problem and need your help.
I created a 3D virtual keyboard that allow users to click on the virtual keys to input information. When user hits the virual "Enter" key, the entered string will be saved in a variable. My applicaiton uses HMD, it's not convenient for user to use the physical keyboard.

My problem is, when I use this virtual keyboard in my system, how can I make my program wait (halt) until the virtual "return" key is pressed (just like the viz.input())? I tried to use event, viztask and signal system to do the synchronization, but somehow can't make it work.
Please give me some help.

Thanks,

Jeff 12-22-2008 10:01 AM

Can you post some code to show how you set up the virtual keyboard?

Jeff 12-22-2008 10:04 AM

If each key is its own node3D object you could use vizact.onpick to call a function that saves your data when the enter object is clicked on.

yyang 12-22-2008 04:43 PM

Quote:

Originally Posted by Jeff (Post 6920)
If each key is its own node3D object you could use vizact.onpick to call a function that saves your data when the enter object is clicked on.

Thanks for your reply. I developed a VRKeyboard class that allows users to use mouse to click on the keys (each one is a 3D object). The values of the keys clicked will be saved to a string variable. When the "Enter" key is pressed, the keyboard will disappear. I use this class as following:

myKeyboard = VRKeyboard() #declare an instance of the class
myKeyboard.Show() #make the 3D keyboard appear on the screen

#The VR keyboard always faces the viewpoint. User now can use mouse
# to click on the keys just like he types on the real keyboard. All the
# key values will be saved in a variable: self.inputString
# When the "Enter" key is pressed, the vr keyboard is hidden.

# I WANT MY PROGRAM TO WAIT HERE UNTIL THE VR KEYBOARD
# INPUT FINISHES. That means I want my program to sit here until
# the user presses the "Enter" on the virtual keyboard.
(I tried to put the VRKeyboard operation in the viz.director(), then use a while statement here to wait for the keyboard input ends. But the while statement freezes the system, including the keyboard input. :confused:).

Do we have any way to make the program stops here while still allow user to click the virtual keys, and after "Enter" is clicked, keep on executing the following sentences?

#Now I can use the myKeyboard.inputString value to do what I want in the
# following sentences.
print myKeyboard.inputString #display the user's input from the VR keyboard.

Jeff 12-23-2008 12:25 PM

Try using viztask to keep track of the flow of your program. You can yield until a signal is sent when your enter node3D is clicked on.

Code:

import viztask

s = viztask.Signal()

def MyTask():

        yield s.wait()
        #save your data
       
       
viztask.schedule( MyTask() )

vizact.onpick(enter_node, s.send)



All times are GMT -7. The time now is 11:42 AM.

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