I m new here.i was trying to use keyboard event in my visual studio project written in c# .i use one form (my_form) and one button (button_1).i would like to add 1 to my protected variable “valore” when i click the button(and here there is obviously no problem),and when i digit the key “a” or “A” on my keyboard .
i tried using the keydown event of the button and also Rhino.RhinoApp.KeyboardHookEvent but the problem is that after the initialization of myform the keydown event works until i click on one of the viewports.in that case the focus goes to the command line and if i digit “A” i only write “A” on the commandline.any suggestion?thanks.sorry Steve i was too tired to see your link to this forum…
I don’t think you attached the correct project. There is very little code in the attached project and nothing in there that has to do with keyboard events.
Instead of doing this:
thank you for replying.i posted a new project as example.i don’t have the complete project because i would like to know how to work with keyboard event before working with a big code.but i wrote some code that could explain what i need.i have two kind of events,the button keydown event and the Rhino.RhinoApp.KeyboardEvent += new Rhino.RhinoApp.KeyboardHookEvent(on_premitasto) event. i don’t want to use form_1.ShowDialog() because i want to interact with viewports and with other commands while my_form is open. the problem with button event is that when clicking on viewport i loose the event.the problem with rhino event is that i don’t loose the event but in the command line i would like not to write anything.probably there is a way to disable commnad line?now i am thinking it would be a solution…thank you very much and please understand if i do something wrong…i m not a professional programmer.
probably you did not see this topic,or you are too busy with other topics much more important for you but i hope you will find one minute for me again.i would like to know only if there is the possibility to do what i said before. if you run the project and the command in rhino it draws one circle and with the key “A” you may add 1 to his diameter , with the key"S" the opposite thing and with any other key you write the value of the key on the command line but the circle remains the same(diameter or radius i don’t remember but here it is not important.)MyProject2.7z(20.5 KB)
the command in rhino is" MyProject1Command"
Keyboard messages are sent to the window that has focus. Thus, when you click on a Rhino viewport, it becomes the focused window and, thus, all keyboard message are sent to it (which in turn are forwarded to Rhino’s command line).
I guess you could try hooking the keyboard. But then all keyboard input will be available, including keystrokes not meant for your plug-in or window. How to you plan on differentiating between what is meant for you windows and what is meant for a different window?
I don’t think any UI in Rhino hooks the keyboard, for what it’s worth…
thank you Dale.it is exactly what i understood by running my project.wath i would like to do is this:
1_ with a checkbox i set enabled the keyboard input that returns different values only for “q”,“w”,“a”,“s”,“z”,“x”.for what concerns the other keyboard input ,it is is better for me if they remain the same.
2_thus it is not important for me which is the active form and the corrispondent keyboard input
3_i would like to clear and hide command line until checkbox is flagged.(i tried SetCommandPrompt("");but you see that command line is clearing itself.
there is a way to hide command line text?
Rhino.RhinoApp.KeyboardEvent += new Rhino.RhinoApp.KeyboardHookEvent(on_premitasto);
I am not sure I understand. Do you want to clear the text from the command history window? Or, so you want to hide the command history window (turn it completely off)?
Hi All.Sorry. i went out for vacation and when back i did not see last reply.
command history window is not the problem.
- if i call Rhino.RhinoApp.KeyboardEvent in the constructor of one of my forms,it works
2)if the form lost focus because i click in a viewport when i press “A” i don’t want to write “A” on the command line but i want to call the Rhino.RhinoApp.KeyboardEvent
3)in case i am inside for example a Getpoint loop and i press the key “A” i don’t want to activate the command line ( and in my case by pressing “A”,i think, it is look like sending a keystroke"A") but i want again to activate the keyboard event Rhino.RhinoApp.KeyboardEvent .
4)when closing my form i would like to stop the event by doing " Rhino.RhinoApp.KeyboardEvent -= new Rhino.RhinoApp.KeyboardHookEvent(RhinoApp_KeyboardEvent);"
This is not possible. If Rhino has focus, then it is going to process all keyboard input, even though you have hooked they keyboard.
Again, it is not possible to steal keystrokes headed to Rhino and use them for your own use. In this case, you should provide a command line option for GetPoint that handles the “A” input.
In Italy we say “you are number one”.thank you very much Dale.i believe it
is logically correct.it is really a good idea to use a command line option
for the getpoint ,i hadn’t thought of it.it is perfect.on monday i will try
and i will post a simple project if it works to show what i mean.thanks
Il giorno 06/set/2013 22:32, “dale via McNeel Forum” email@example.com ha