Fixed menu and shortcut handling (STR #2243)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@7848 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
43447f0f95
commit
4bf4c6d8ed
1
CHANGES
1
CHANGES
@ -3,6 +3,7 @@ CHANGES IN FLTK 1.1.11
|
||||
- Documentation fixes (STR #2410)
|
||||
- Fixed mouse wheel related crash in GLUT emulation (STR #2381)
|
||||
- Fixed missing architecture flags in OS X build (STR #2303)
|
||||
- Fixed menu and shortcut handling (STR #2243)
|
||||
|
||||
CHANGES IN FLTK 1.1.10
|
||||
|
||||
|
||||
@ -129,6 +129,7 @@ struct FL_EXPORT Fl_Menu_Item {
|
||||
int menubar=0) const;
|
||||
const Fl_Menu_Item* test_shortcut() const;
|
||||
const Fl_Menu_Item* find_shortcut(int *ip=0) const;
|
||||
const Fl_Menu_Item* find_shortcut(int *ip, int require_alt) const;
|
||||
|
||||
void do_callback(Fl_Widget* o) const {callback_(o, user_data_);}
|
||||
void do_callback(Fl_Widget* o,void* arg) const {callback_(o, arg);}
|
||||
|
||||
@ -190,6 +190,7 @@ public:
|
||||
int test_shortcut();
|
||||
static char label_shortcut(const char *t);
|
||||
static int test_shortcut(const char*);
|
||||
static int test_shortcut(const char*, int require_alt);
|
||||
int contains(const Fl_Widget*) const ;
|
||||
int inside(const Fl_Widget* o) const {return o ? o->contains(this) : 0;}
|
||||
|
||||
|
||||
@ -899,22 +899,26 @@ Fl_Menu_Item::popup(
|
||||
int X, int Y,
|
||||
const char* title,
|
||||
const Fl_Menu_Item* picked,
|
||||
const Fl_Menu_* but
|
||||
const Fl_Menu_* button
|
||||
) const
|
||||
{
|
||||
static Fl_Menu_Item dummy; // static so it is all zeros
|
||||
dummy.text = title;
|
||||
return pulldown(X, Y, 0, 0, picked, but, title ? &dummy : 0);
|
||||
return pulldown(X, Y, 0, 0, picked, button, title ? &dummy : 0);
|
||||
}
|
||||
|
||||
const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const {
|
||||
return find_shortcut(ip, 0);
|
||||
}
|
||||
|
||||
// Search only the top level menu for a shortcut. Either &x in the
|
||||
// label or the shortcut fields are used:
|
||||
const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip) const {
|
||||
const Fl_Menu_Item* Fl_Menu_Item::find_shortcut(int* ip, int require_alt) const {
|
||||
const Fl_Menu_Item* m = first();
|
||||
if (m) for (int ii = 0; m->text; m = m->next(), ii++) {
|
||||
if (m->activevisible()) {
|
||||
if (Fl::test_shortcut(m->shortcut_)
|
||||
|| Fl_Widget::test_shortcut(m->text)) {
|
||||
|| Fl_Widget::test_shortcut(m->text, require_alt)) {
|
||||
if (ip) *ip=ii;
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ int Fl_Menu_Bar::handle(int event) {
|
||||
return 1;
|
||||
case FL_SHORTCUT:
|
||||
if (visible_r()) {
|
||||
v = menu()->find_shortcut();
|
||||
v = menu()->find_shortcut(0, true);
|
||||
if (v && v->submenu()) goto J1;
|
||||
}
|
||||
return test_shortcut() != 0;
|
||||
|
||||
@ -221,11 +221,13 @@ char Fl_Widget::label_shortcut(const char *t) {
|
||||
}
|
||||
}
|
||||
|
||||
int Fl_Widget::test_shortcut(const char *t) {
|
||||
#ifdef WIN32
|
||||
// on MSWindows, users expect shortcuts to work only when the Alt modifier is pressed
|
||||
if (Fl::event_state(FL_ALT)==0) return 0;
|
||||
#endif
|
||||
int Fl_Widget::test_shortcut(const char *ti) {
|
||||
return test_shortcut(ti, 0);
|
||||
}
|
||||
|
||||
int Fl_Widget::test_shortcut(const char *t, int require_alt) {
|
||||
// for menubars etc. shortcuts must work only if the Alt modifier is pressed
|
||||
if (require_alt && Fl::event_state(FL_ALT)==0) return 0;
|
||||
char c = Fl::event_text()[0];
|
||||
if (!c || !t) return 0;
|
||||
if (c == label_shortcut(t))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user