STR 1213: leaving the area of a menubar when dragging would not cancel out the menu selection. This version now deselects a menu if the mouse leaves a menu structure, moving or dragging.
This is an extension of the original patch which would file on selecting menu titles, or returning to the previous menu window inside a menu hierarchy. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4866 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
7d8d1883d5
commit
094f1b0f7e
@ -107,6 +107,7 @@ public:
|
||||
int titlex(int);
|
||||
void autoscroll(int);
|
||||
void position(int x, int y);
|
||||
int is_inside(int x, int y);
|
||||
};
|
||||
|
||||
#define LEADING 4 // extra vertical leading
|
||||
@ -458,6 +459,15 @@ int menuwindow::titlex(int n) {
|
||||
return xx;
|
||||
}
|
||||
|
||||
// return 1, if the given root coordinates are inside the window
|
||||
int menuwindow::is_inside(int mx, int my) {
|
||||
if ( mx < x_root() || mx >= x_root() + w() ||
|
||||
my < y_root() || my >= y_root() + h()) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Fl_Menu_Item::popup(...)
|
||||
|
||||
@ -488,9 +498,20 @@ struct menustate {
|
||||
int nummenus;
|
||||
int menubar; // if true p[0] is a menubar
|
||||
int state;
|
||||
int is_inside(int mx, int my);
|
||||
};
|
||||
static menustate* p;
|
||||
|
||||
// return 1 if the coordinates are inside any of the menuwindows
|
||||
int menustate::is_inside(int mx, int my) {
|
||||
int i;
|
||||
for (i=nummenus-1; i>=0; i--) {
|
||||
if (p[i]->is_inside(mx, my))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void setitem(const Fl_Menu_Item* i, int m, int n) {
|
||||
p->current_item = i;
|
||||
p->menu_number = m;
|
||||
@ -595,14 +616,11 @@ int menuwindow::handle(int e) {
|
||||
int mx = Fl::event_x_root();
|
||||
int my = Fl::event_y_root();
|
||||
int item=0; int mymenu = pp.nummenus-1;
|
||||
if (e == FL_PUSH && (!pp.menubar || mymenu) &&
|
||||
(mx < pp.p[mymenu]->x_root() ||
|
||||
mx >= (pp.p[mymenu]->x_root() + pp.p[mymenu]->w()) ||
|
||||
my < pp.p[mymenu]->y_root() ||
|
||||
my >= (pp.p[mymenu]->y_root() + pp.p[mymenu]->h()))) {
|
||||
// Clicking outside menu cancels it...
|
||||
// Clicking or dragging outside menu cancels it...
|
||||
if ((!pp.menubar || mymenu) && !pp.is_inside(mx, my)) {
|
||||
setitem(0, -1, 0);
|
||||
pp.state = DONE_STATE;
|
||||
if (e==FL_PUSH)
|
||||
pp.state = DONE_STATE;
|
||||
return 1;
|
||||
}
|
||||
for (mymenu = pp.nummenus-1; ; mymenu--) {
|
||||
|
Loading…
Reference in New Issue
Block a user