Merge pull request #2029 from actionless/calendar-fix-click-hide

Calendar popup click/hover fix
This commit is contained in:
Daniel Hahler 2017-09-09 05:14:02 +02:00 committed by GitHub
commit 66c4e55511
1 changed files with 12 additions and 6 deletions

View File

@ -256,24 +256,24 @@ function calendar_popup:attach(widget, position, args)
if args.on_hover == nil then args.on_hover=true end
widget:buttons(gears.table.join(
abutton({ }, 1, function ()
if not self.visible or self._calendar_clicked then
if not self.visible or self._calendar_clicked_on then
self:call_calendar(0, position)
self.visible = not self.visible
end
self._calendar_clicked = self.visible
self._calendar_clicked_on = self.visible
end),
abutton({ }, 4, function () self:call_calendar(-1) end),
abutton({ }, 5, function () self:call_calendar( 1) end)
))
if args.on_hover then
widget:connect_signal("mouse::enter", function ()
if not self._calendar_clicked then
if not self._calendar_clicked_on then
self:call_calendar(0, position)
self.visible = true
end
end)
widget:connect_signal("mouse::leave", function ()
if not self._calendar_clicked then
if not self._calendar_clicked_on then
self.visible = false
end
end)
@ -332,8 +332,14 @@ local function get_cal_wibox(caltype, args)
ret:set_widget(widget)
ret:buttons(gears.table.join(
abutton({ }, 1, function () ret.visible=false end),
abutton({ }, 3, function () ret.visible=false end),
abutton({ }, 1, function ()
ret.visible=false
ret._calendar_clicked_on=false
end),
abutton({ }, 3, function ()
ret.visible=false
ret._calendar_clicked_on=false
end),
abutton({ }, 4, function () ret:call_calendar(-1) end),
abutton({ }, 5, function () ret:call_calendar( 1) end)
))