some fixes in MainWindow move

master
Eduardo Bart 12 years ago
parent 876c521d43
commit 37f3f904c7

@ -8,13 +8,18 @@ Window < UIWindow
image-source: /core_styles/images/window.png
image-border: 4
image-border-top: 20
opacity: 1
padding-top: 28
padding-left: 16
padding-right: 16
padding-bottom: 16
$disabled:
color: #aaaaaa88
$pressed:
opacity: 0.8
MainWindow < Window
anchors.centerIn: parent

@ -10,5 +10,6 @@ end
function UICheckBox:onMouseRelease(mousePos, mouseButton)
if self:isPressed() and self:containsPoint(mousePos) then
self:setChecked(not self:isChecked())
return true
end
end

@ -10,6 +10,7 @@ function UIMiniWindow:onMousePress(mousePos, mouseButton)
if parent:getClassName() ~= 'UIMiniWindowContainer' then
self:raise()
end
return true
end
function UIMiniWindow:onDragEnter(mousePos)

@ -51,9 +51,8 @@ function UIPopupMenu:onMousePress(mousePos, mouseButton)
-- clicks outside menu area destroys the menu
if not self:containsPoint(mousePos) then
self:destroy()
return true
end
return false
return true
end
function UIPopupMenu:onKeyPress(keyCode, keyboardModifiers)

@ -18,7 +18,8 @@ function UIWindow:onKeyPress(keyCode, keyboardModifiers)
end
function UIWindow:onMousePress(mousePos, mouseButton)
self:raise()
return true
end
function UIWindow:onDragEnter(mousePos)

@ -32,6 +32,18 @@ LuaObject::~LuaObject()
releaseLuaFieldsTable();
}
bool LuaObject::hasLuaField(const std::string& field)
{
bool ret = false;
if(m_fieldsTableRef != -1) {
g_lua.getRef(m_fieldsTableRef);
g_lua.getField(field); // push the field value
ret = !g_lua.isNil();
g_lua.pop(2);
}
return ret;
}
void LuaObject::releaseLuaFieldsTable()
{
if(m_fieldsTableRef != -1) {

@ -40,6 +40,8 @@ public:
template<typename R, typename... T>
R callLuaField(const std::string& field, const T&... args);
bool hasLuaField(const std::string& field);
/// Sets a field in this lua object
template<typename T>
void setLuaField(const std::string& key, const T& value);

@ -1191,7 +1191,10 @@ bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
} else
m_clickTimer.restart();
}
return callLuaField<bool>("onMousePress", mousePos, button);
if(hasLuaField("onMousePress"))
return callLuaField<bool>("onMousePress", mousePos, button);
return true;
}
bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)

@ -319,7 +319,7 @@ public:
void setPaddingRight(int padding) { m_padding.right = padding; updateLayout(); }
void setPaddingBottom(int padding) { m_padding.bottom = padding; updateLayout(); }
void setPaddingLeft(int padding) { m_padding.left = padding; updateLayout(); }
void setOpacity(float opacity) { m_opacity = opacity; }
void setOpacity(float opacity) { m_opacity = std::min(std::max(opacity, 0.0f), 1.0f); }
int getX() { return m_rect.x(); }
int getY() { return m_rect.y(); }

Loading…
Cancel
Save