move tooltip and messagebox to modules

master
Eduardo Bart 13 years ago
parent a9bf1cee36
commit 6aadf896da

@ -17,7 +17,5 @@ Module
require 'widget'
require 'ui'
require 'gfx'
require 'messagebox/messagebox'
require 'tooltip/tooltip'
return true

@ -23,17 +23,7 @@ Button < UIButton
color: #999999
background-color: #ffffff88
ToolTipButton < UIButton
onHoverChange: |
function(self, hovered)
if hovered then
ToolTip.display(self:getStyle().tooltip)
else
ToolTip:hide()
end
end
TopButton < ToolTipButton
TopButton < UIButton
background-color: white
size: 26 25
text-translate: 0 0

@ -10,7 +10,7 @@ function MessageBox.create(title, text, flags)
setmetatable(box, MessageBox)
-- create messagebox window
local window = UI.loadAndDisplayLocked('/core/messagebox/messagebox.otui')
local window = UI.loadAndDisplayLocked('/messagebox/messagebox.otui')
window:setTitle(title)
local label = window:getChildById('messageBoxLabel')

@ -0,0 +1,12 @@
Module
name: messagebox
description: Manages message boxes
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
dependencies:
- core
onLoad: |
require 'messagebox'
return true

@ -16,11 +16,19 @@ local function moveToolTip(tooltip)
tooltip:moveTo(pos)
end
local function onButtonHoverChange(button, hovered)
if hovered then
ToolTip.display(button:getStyle().tooltip)
else
ToolTip:hide()
end
end
-- public functions
function ToolTip.display(text)
ToolTip.hide()
if text then
currentToolTip = UI.loadAndDisplay('/core/tooltip/tooltip.otui', UI.root)
currentToolTip = UI.loadAndDisplay('/tooltip/tooltip.otui', UI.root)
currentToolTip.onMouseMove = moveToolTip
local label = currentToolTip:getChildById('toolTipText')
label:setText(text)
@ -39,3 +47,6 @@ function ToolTip.hide()
currentToolTip = nil
end
end
-- hooks
connect(UIButton, { onHoverChange = onButtonHoverChange})

@ -0,0 +1,12 @@
Module
name: tooltip
description: Enable tooltips on any button
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
dependencies:
- core
onLoad: |
require 'tooltip'
return true
Loading…
Cancel
Save