Sdk/ButtonWidget: Make buttons clickable

Former-commit-id: a2a018254f6f6ebc36f402e6cec12b5ab048d4c3 [formerly d3a5c72ac4b0df83cb1100ea0f58b2c03e029d18] [formerly 404765b9f0bac1b2b41e594783ae730c15c7dfc0 [formerly e0628754a233a7cde8ffa60e02e4614dc3d9961e]]
Former-commit-id: 127c9d5cd50790a3003fd4a6ea4c21b17526c7ae [formerly 545310c49f5a4e118cf089480e7c7321f09719a0]
Former-commit-id: 217ef14e8265f3bb469e859e61c1a18e5f8e5c14
This commit is contained in:
Lynix 2016-09-16 16:56:10 +02:00
parent 8ad2f05abd
commit 061261b911
2 changed files with 9 additions and 0 deletions

View File

@ -34,11 +34,14 @@ namespace Ndk
ButtonWidget& operator=(const ButtonWidget&) = delete; ButtonWidget& operator=(const ButtonWidget&) = delete;
ButtonWidget& operator=(ButtonWidget&&) = default; ButtonWidget& operator=(ButtonWidget&&) = default;
NazaraSignal(OnButtonTrigger, const ButtonWidget* /*button*/);
private: private:
void Layout() override; void Layout() override;
void OnMouseEnter() override; void OnMouseEnter() override;
void OnMouseMoved(int x, int y, int deltaX, int deltaY) 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; void OnMouseExit() override;
EntityHandle m_textEntity; 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); 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() void ButtonWidget::OnMouseEnter()
{ {
m_gradientSprite->SetColor(Nz::Color(128, 128, 128)); m_gradientSprite->SetColor(Nz::Color(128, 128, 128));