code_uiclicklabel.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // UIClickLabel application source code
  2. #include "PeriodicApp.h"
  3. void PeriodicApp::setup_uiclicklabel( 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, HandleUiclicklabelEvent ));
  9. UIWidget *chk1 = layout->GetWidget ("somecheck");
  10. if (chk1)
  11. SubscribeToEvent(chk1, E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUiclicklabelEvent ));
  12. UIWidget *chk2 = layout->GetWidget ("someradio");
  13. if (chk2)
  14. SubscribeToEvent(chk2, E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUiclicklabelEvent ));
  15. }
  16. void PeriodicApp::HandleUiclicklabelEvent(StringHash eventType, VariantMap& eventData)
  17. {
  18. using namespace WidgetEvent;
  19. UIWidget* widget = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
  20. if ( widget == NULL ) return;
  21. if (eventData[P_TYPE] == UI_EVENT_TYPE_CLICK)
  22. {
  23. if (widget->GetId() == "uiclicklabelcode" )
  24. {
  25. AppLog( "UIClickLabel support : " + widget->GetId() + " was pressed " );
  26. ViewCode ( "Components/code_uiclicklabel.cpp", widget->GetParent() );
  27. }
  28. if (widget->GetId() == "uiclicklabellayout" )
  29. {
  30. AppLog( "UIClickLabel support : " + widget->GetId() + " was pressed ");
  31. ViewCode ( "Scenes/layout_uiclicklabel.ui.txt", widget->GetParent() );
  32. }
  33. if (widget->GetId() == "somecheck" )
  34. {
  35. AppLog( "UIClickLabel event : " + widget->GetId() + " was pressed, state = " + String ( widget->GetValue() ) );
  36. }
  37. if (widget->GetId() == "someradio" )
  38. {
  39. AppLog( "UIClickLabel event : " + widget->GetId() + " was pressed, state = " + String ( widget->GetValue() ) );
  40. }
  41. }
  42. }