code_uibutton.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // UIButton application source code
  2. #include "PeriodicApp.h"
  3. void PeriodicApp::setup_uibutton( UIWidget *layout)
  4. {
  5. PODVector<UIWidget*> dest;
  6. layout->SearchWidgetClass( "TBButton", dest );
  7. for (unsigned ii = 0; ii < dest.Size(); ii++)
  8. SubscribeToEvent(dest[ii], E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUibuttonEvent ));
  9. }
  10. void PeriodicApp::HandleUibuttonEvent(StringHash eventType, VariantMap& eventData)
  11. {
  12. using namespace WidgetEvent;
  13. UIWidget* widget = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
  14. if ( widget == NULL ) return;
  15. if (eventData[P_TYPE] == UI_EVENT_TYPE_CLICK)
  16. {
  17. if (widget->GetId() == "uibuttoncode" )
  18. {
  19. AppLog( "UIButton support : " + widget->GetId() + " was pressed " );
  20. ViewCode ( "Components/code_uibutton.cpp", widget->GetParent() );
  21. }
  22. if (widget->GetId() == "uibuttonlayout" )
  23. {
  24. AppLog( "UIButton support : " + widget->GetId() + " was pressed ");
  25. ViewCode ( "Scenes/layout_uibutton.ui.txt", widget->GetParent() );
  26. }
  27. if (widget->GetId() == "demobutton" )
  28. {
  29. AppLog( "UIButton action : " + widget->GetId() + " was pressed ");
  30. }
  31. if (widget->GetId() == "buttonducky" )
  32. {
  33. AppLog( "UIButton action : " + widget->GetId() + " was pressed ");
  34. }
  35. if (widget->GetId() == "buttonready" )
  36. {
  37. AppLog( "UIButton action : " + widget->GetId() + " was pressed ");
  38. }
  39. if (widget->GetId() == "buttonatomic" )
  40. {
  41. AppLog( "UIButton action : " + widget->GetId() + " was pressed ");
  42. }
  43. if (widget->GetId() == "buttongreen" )
  44. {
  45. AppLog( "UIButton action : " + widget->GetId() + " was pressed ");
  46. }
  47. }
  48. }