Skip to content

Commit

Permalink
improve MenuBar mouse move
Browse files Browse the repository at this point in the history
  • Loading branch information
NotFound committed Dec 14, 2011
1 parent bf95e5e commit 9eb42c8
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/Guitor.winxed
Expand Up @@ -2755,6 +2755,7 @@ class MenuBarWindow : ChildWindow
var itempos;
var height;
var active;
var curitem;
var child;
function MenuBarWindow(parent, int x, int y, int width, menubar)
{
Expand Down Expand Up @@ -2803,6 +2804,17 @@ class MenuBarWindow : ChildWindow
}
return -1;
}
function activate(int nitem)
{
__ASSERT__(nitem >= 0);
__ASSERT__(nitem < elements(self.itempos));
if (self.child != null)
self.child.Destroy();
self.curitem = nitem;
int x = self.itempos[nitem];
var action = self.menubar.items[nitem].action;
self.child = action.open(self.parent, x, self.height - 4);
}
function onexpose(event)
{
int baseline = self.menubar.font.getAscent() + 2;
Expand All @@ -2822,11 +2834,8 @@ class MenuBarWindow : ChildWindow
int x = event.x();
int y = event.y();
int nitem = self.itemAt(x);
if (nitem != -1) {
int x = self.itempos[nitem];
var action = self.menubar.items[nitem].action;
self.child = action.open(self.parent, x, self.height - 4);
}
if (nitem != -1)
self.activate(nitem);
}
function onbuttonrelease(event)
{
Expand Down Expand Up @@ -2866,8 +2875,16 @@ class MenuBarWindow : ChildWindow
child.setcurrent(win_x - child.x, win_y - child.y);
}
else {
if (child != null)
child.setcurrent(-1, -1);
if (child_p == self.getDID()) {
int curitem = self.curitem;
int nitem = self.itemAt(event.x());
if (nitem != -1 && nitem != curitem)
self.activate(nitem);
}
else {
if (child != null)
child.setcurrent(-1, -1);
}
}
}
else {
Expand Down

0 comments on commit 9eb42c8

Please sign in to comment.