Skip to content

Commit

Permalink
#273 Fixed the ribbons not highlighting correctly when hovering on an…
Browse files Browse the repository at this point in the history
…d off them
  • Loading branch information
Francisco Arrieta committed Jan 2, 2017
1 parent 15e4b4b commit 53ecd86
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions odmtools/gui/mnuRibbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def _init_ctrls(self, prnt):

# -------------------------------------------------------------------------------
editPage = RB.RibbonPage(self, wx.ID_ANY, "Edit")
# editPage.Bind(wx.EVT_ENTER_WINDOW, self.on_mouse_enter)

main_panel = RB.RibbonPanel(editPage, wx.ID_ANY, "Main", wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize,
RB.RIBBON_PANEL_NO_AUTO_MINIMISE)
Expand Down Expand Up @@ -204,14 +205,28 @@ def _init_ctrls(self, prnt):
self.CurrPage = 1
self.SetActivePageByIndex(self.CurrPage)

self.bindEvents()
self.__bind_events()
self.initPubSub()

def __init__(self, parent, id, name):
self.parent = parent
self._init_ctrls(parent)

def bindEvents(self):
def on_mouse_enter(self, event):
ribbon_panel = event.GetEventObject().GetParent()
ribbon_panel._hovered = True

self.Refresh()
event.Skip()

def on_mouse_leave(self, event):
ribbon_panel = event.GetEventObject().GetParent()
ribbon_panel._hovered = False

self.Refresh()
event.Skip()

def __bind_events(self):
###Docking Window Selection
self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.onDocking, id=wxID_RIBBONVIEWTABLE)
self.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.onDocking, id=wxID_RIBBONVIEWSERIES)
Expand Down Expand Up @@ -262,6 +277,24 @@ def bindEvents(self):
###Ribbon Event
self.Bind(RB.EVT_RIBBONBAR_PAGE_CHANGED, self.onFileMenu, id=wxID_PANEL1)

# ENTER
self.main_bar.Bind(wx.EVT_ENTER_WINDOW, self.on_mouse_enter) # 1
self.edit_bar.Bind(wx.EVT_ENTER_WINDOW, self.on_mouse_enter) # 2
self.record_bar.Bind(wx.EVT_ENTER_WINDOW, self.on_mouse_enter) # 3
self.PlotsOptions_bar.Bind(wx.EVT_ENTER_WINDOW, self.on_mouse_enter) # 4
self.plots_bar.Bind(wx.EVT_ENTER_WINDOW, self.on_mouse_enter) # 5
self.dateTime_buttonbar.Bind(wx.EVT_ENTER_WINDOW, self.on_mouse_enter) # 6
self.scriptBar.Bind(wx.EVT_ENTER_WINDOW, self.on_mouse_enter) # 7

# LEAVE
self.main_bar.Bind(wx.EVT_LEAVE_WINDOW, self.on_mouse_leave) # 1
self.edit_bar.Bind(wx.EVT_LEAVE_WINDOW, self.on_mouse_leave) # 2
self.record_bar.Bind(wx.EVT_LEAVE_WINDOW, self.on_mouse_leave) # 3
self.PlotsOptions_bar.Bind(wx.EVT_LEAVE_WINDOW, self.on_mouse_leave) # 4
self.plots_bar.Bind(wx.EVT_LEAVE_WINDOW, self.on_mouse_leave) # 5
self.dateTime_buttonbar.Bind(wx.EVT_LEAVE_WINDOW, self.on_mouse_leave) # 6
self.scriptBar.Bind(wx.EVT_LEAVE_WINDOW, self.on_mouse_leave) # 7

def initPubSub(self):
Publisher.subscribe(self.toggleEditButtons, "EnableEditButtons")
Publisher.subscribe(self.enableButtons, "EnablePlotButtons")
Expand Down

0 comments on commit 53ecd86

Please sign in to comment.