Add some widget layout and ability event handling.
This commit is contained in:
parent
b99708e7d3
commit
4e85edacc8
24 changed files with 285 additions and 31 deletions
|
@ -3,7 +3,8 @@
|
|||
|
||||
Button::Button()
|
||||
: Widget(),
|
||||
mLabel()
|
||||
mLabel(),
|
||||
mClickFunc()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -13,6 +14,11 @@ std::unique_ptr<Button> Button::Create()
|
|||
return std::make_unique<Button>();
|
||||
}
|
||||
|
||||
void Button::SetOnClickFunction(clickFunc func)
|
||||
{
|
||||
mClickFunc = func;
|
||||
}
|
||||
|
||||
void Button::SetLabel(const std::string& text)
|
||||
{
|
||||
mLabel = text;
|
||||
|
@ -22,8 +28,15 @@ void Button::OnMyMouseEvent(const MouseEvent* event)
|
|||
{
|
||||
if(event->GetAction() == MouseEvent::Action::Pressed)
|
||||
{
|
||||
std::cout << "Clicked !!" << std::endl;
|
||||
SetBackgroundColor(Color::Create(0, 255, 0));
|
||||
if(mClickFunc)
|
||||
{
|
||||
mClickFunc();
|
||||
}
|
||||
}
|
||||
else if(event->GetAction() == MouseEvent::Action::Released)
|
||||
{
|
||||
SetBackgroundColor(Color::Create(0, 255, 255));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue