mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
some fixes in MainWindow move
This commit is contained in:
@@ -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(); }
|
||||
|
Reference in New Issue
Block a user