Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / accelertor entry

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. accelertor entry
#3181
Posted by: 2004-01-03 11:29:24
hi, I have a user interface with some buttons and a textbox.
The buttons are supposed to be activated by pressing characters, but NOT when the textbox is selected. Then the characters should be entered in the textbox.

Also, this program plays back music, and the space bar is supposed to activate the play / stop function. but it should NOT activate the currently selected control.

Now i used accelerator entries for these chars and space, but this gives the problem:

-I cannot enter the chars used in the accelerator table in the text box.
-When space is pressed, not only will the program start or stop playing, the currently selected controll is also activated.

I know i could solve the first problem by using shft, ctrl or alt with the keys to activate the functions, but that is only a last resort, if possible without those, i want it without shift crtl and alt.

-Is there a way to not make controlls react to the space?

-Is there a way to bypass the accelerator table when the textbox is selected?

-Is there a key event in wxwindows so that i could make an event handler that is activated whenever a key is pressed. Then have the event handler check what controlls are selected, decide what shoult happen and call the appropriate function.
In the documentation i see only writen about mouse.event, not key event. Also if there is a possibility to do this, i would be very happy if you could give me some directions on how to do this. (how to pass the event to the textbox when the textbox is selected)

thanx in advance.
Message2. Re: accelertor entry
#3182
Posted by: KaReL 2004-01-03 15:05:37
I think it's pretty easy :)

You have to create your own class of each control you're using. Probably you're doing something like wxText * text = new wxText(this,-1) ... etc ...

This however will not be able to catch any events...

Now if you do this:

--h--
class MyTextControl : public wxText
{
// Do nothing (this means: take everything from above (in hierarchy: wxText) control

  DECLARE_EVENT_TABLE();
}

--cpp--
BEGIN_EVENT_TABLE(MyTextControl, wxText)
EVT_CHAR ( MyTextControl::On_KeyEvent )
END_EVENT_TABLE()

it could be evt_char_hook or evt_key_down too...

In this event you should use StopPropagating or something like that, which means .... "I have handled the event, beat it now!"

Do the same for every button, where you check the char-key you want to activate the button with & the space bar...


There could be another way, but that's how I should do it ;)

------------------------
Website: www.KaReLs0ft.be
Message3. Re: accelertor entry
#3183
Posted by: KaReL 2004-01-03 15:24:04
Check this out:
http://wiki.wxwindows.org/wiki.pl?Events

------------------------
Website: www.KaReLs0ft.be
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sun 2022-12-4  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0