Sdk/ButtonWidget: Make buttons clickable

Former-commit-id: 999f91775de93746f964b5a8d9276208cd8a592b [formerly e135030f2cb801715242168c305950d8991f38f1] [formerly 9e88a4002c5293aa0f96585e23992e6b539961a4 [formerly ad29706e81fe2facde2a1e669ac0e0b558f0ae0a]]
Former-commit-id: 32b8c7ebe3a5bccd02fa929471548b8872bdac16 [formerly 5d1450890b7dc43e967e3e1431f2ceb6c415b655]
Former-commit-id: 21f53b1616bc5c367f7696c86781e5dad8455335
This commit is contained in:
Lynix 2016-09-16 16:56:10 +02:00
parent 9ea02e8b81
commit 7a111101e6
2 changed files with 9 additions and 0 deletions

View File

@ -34,11 +34,14 @@ namespace Ndk
ButtonWidget& operator=(const ButtonWidget&) = delete;
ButtonWidget& operator=(ButtonWidget&&) = default;
NazaraSignal(OnButtonTrigger, const ButtonWidget* /*button*/);
private:
void Layout() override;
void OnMouseEnter() override;
void OnMouseMoved(int x, int y, int deltaX, int deltaY) override;
void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button) override;
void OnMouseExit() override;
EntityHandle m_textEntity;

View File

@ -48,6 +48,12 @@ namespace Ndk
m_textEntity->GetComponent<NodeComponent>().SetPosition(contentSize.x / 2 - textBox.width / 2, contentSize.y / 2 - textBox.height / 2);
}
void ButtonWidget::OnMouseButtonRelease(int /*x*/, int /*y*/, Nz::Mouse::Button button)
{
if (button == Nz::Mouse::Left)
OnButtonTrigger(this);
}
void ButtonWidget::OnMouseEnter()
{
m_gradientSprite->SetColor(Nz::Color(128, 128, 128));