Home » U++ Library support » U++ Widgets - General questions or Mixed problems » how to define hot-keys not associated with any menu?
how to define hot-keys not associated with any menu? [message #19875] |
Wed, 28 January 2009 22:53 |
White_Owl
Messages: 27 Registered: January 2009 Location: New York
|
Promising Member |
|
|
I have my own widget(s) inside TopWindow, this widget should react to hot-keys. Only widget itself knows what these keys are.
So I am trying to do:
class MainWindow: public TopWindow {
BaseWidget widget*;
};
void MainWindow::ChooseWidget() {
widget = WidgetFactory(widget_id);
this.Add(&*widget);
widget->SetupHotKeys(this);
} Widgets are defined like this:class BaseWidget: public Ctrl {
public:
virtual void SetupHotKeys(TopWindow &tw) = 0;
};
class RealWidget: public BaseWidget {
void foo1();
void foo2();
void SetupHotKeys(TopWindow &tw) {
tw.SomeKindOfAssignKey(K_A, THISBACK(foo1));
tw.SomeKindOfAssignKey(K_SHIFT_A, THISBACK(foo2));
}
};
So the question is what is the name of the function which does actual key assignments? Am I going in the right direction? Any tutorial or examples with similar functionality?
|
|
|
Re: how to define hot-keys not associated with any menu? [message #19990 is a reply to message #19875] |
Sun, 08 February 2009 08:18 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
IMO you can start here:
dword Switch::GetAccessKeys() const
{
dword keys = 0;
for(int i = 0; i < cs.GetCount(); i++)
keys |= AccessKeyBit(cs[i].accesskey);
return keys;
}
void Switch::AssignAccessKeys(dword used)
{
for(int i = 0; i < cs.GetCount(); i++) {
Case& v = cs[i];
if(!v.accesskey) {
v.accesskey = ChooseAccessKey(v.label, used);
if(v.accesskey) Refresh();
used |= AccessKeyBit(v.accesskey);
}
}
Ctrl::AssignAccessKeys(used);
}
Note that U++ normally assigns hotkeys automatically, but you can override that using venerable "&" (ChooseAccessKey takes care about all of that).
Mirek
[Updated on: Sun, 08 February 2009 08:19] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Sep 20 12:39:54 CEST 2024
Total time taken to generate the page: 0.02727 seconds
|