2012-06-26 00:13:30 +02:00
|
|
|
-- @docclass
|
2014-06-06 18:10:14 +02:00
|
|
|
UIWindow = extends(UIWidget, "UIWindow")
|
2012-01-11 00:13:38 +01:00
|
|
|
|
|
|
|
function UIWindow.create()
|
|
|
|
local window = UIWindow.internalCreate()
|
|
|
|
window:setTextAlign(AlignTopCenter)
|
2012-08-07 01:43:14 +02:00
|
|
|
window:setDraggable(true)
|
2013-01-26 20:06:25 +01:00
|
|
|
window:setAutoFocusPolicy(AutoFocusFirst)
|
2012-01-11 00:13:38 +01:00
|
|
|
return window
|
|
|
|
end
|
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
function UIWindow:onKeyDown(keyCode, keyboardModifiers)
|
2012-01-11 00:13:38 +01:00
|
|
|
if keyboardModifiers == KeyboardNoModifier then
|
2012-02-04 03:11:18 +01:00
|
|
|
if keyCode == KeyEnter then
|
2012-01-11 00:13:38 +01:00
|
|
|
signalcall(self.onEnter, self)
|
|
|
|
elseif keyCode == KeyEscape then
|
|
|
|
signalcall(self.onEscape, self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-01-19 05:12:53 +01:00
|
|
|
|
2012-02-20 03:27:08 +01:00
|
|
|
function UIWindow:onFocusChange(focused)
|
|
|
|
if focused then self:raise() end
|
2012-01-19 05:12:53 +01:00
|
|
|
end
|
|
|
|
|
2012-02-07 01:41:53 +01:00
|
|
|
function UIWindow:onDragEnter(mousePos)
|
|
|
|
self:breakAnchors()
|
|
|
|
self.movingReference = { x = mousePos.x - self:getX(), y = mousePos.y - self:getY() }
|
2012-02-09 19:38:50 +01:00
|
|
|
return true
|
2012-02-07 01:41:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function UIWindow:onDragLeave(droppedWidget, mousePos)
|
|
|
|
-- TODO: auto detect and reconnect anchors
|
|
|
|
end
|
2012-01-19 05:12:53 +01:00
|
|
|
|
2012-02-07 01:41:53 +01:00
|
|
|
function UIWindow:onDragMove(mousePos, mouseMoved)
|
|
|
|
local pos = { x = mousePos.x - self.movingReference.x, y = mousePos.y - self.movingReference.y }
|
|
|
|
self:setPosition(pos)
|
|
|
|
self:bindRectToParent()
|
2012-01-19 05:12:53 +01:00
|
|
|
end
|