code_uipromptwindow.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // UIPromptWindow application source code
  2. #include <Atomic/UI/UIEvents.h>
  3. #include <Atomic/UI/UIPromptWindow.h>
  4. #include "PeriodicApp.h"
  5. void PeriodicApp::setup_uipromptwindow( UIWidget *layout, UIView *uiview )
  6. {
  7. PODVector<UIWidget*> dest;
  8. layout->SearchWidgetClass( "TBButton", dest );
  9. for (unsigned ii = 0; ii < dest.Size(); ii++)
  10. SubscribeToEvent(dest[ii], E_WIDGETEVENT, ATOMIC_HANDLER(PeriodicApp, HandleUipromptwindowEvent ));
  11. }
  12. void PeriodicApp::HandlePromptCompleteEvent(StringHash eventType, VariantMap& eventData)
  13. {
  14. using namespace UIPromptComplete;
  15. AppLog( "UIPromptWindow event : the window " + eventData[P_TITLE].GetString()
  16. + " file was " + eventData[P_SELECTED].GetString()
  17. + ", the button pressed was " + eventData[P_REASON].GetString());
  18. }
  19. void PeriodicApp::HandleUipromptwindowEvent(StringHash eventType, VariantMap& eventData)
  20. {
  21. using namespace WidgetEvent;
  22. UIWidget* widget = static_cast<UIWidget*>(eventData[P_TARGET].GetPtr());
  23. if ( widget == NULL ) return;
  24. if (eventData[P_TYPE] == UI_EVENT_TYPE_CLICK)
  25. {
  26. if (widget->GetId() == "uipromptwindowcode" )
  27. {
  28. AppLog( "UIPromptWindow support : " + widget->GetId() + " was pressed " );
  29. ViewCode ( "Components/code_uipromptwindow.cpp", widget->GetParent() );
  30. }
  31. if (widget->GetId() == "uipromptwindowlayout" )
  32. {
  33. AppLog( "UIPromptWindow support : " + widget->GetId() + " was pressed ");
  34. ViewCode ( "Scenes/layout_uipromptwindow.ui.txt", widget->GetParent() );
  35. }
  36. if (widget->GetId() == "stringfinder" )
  37. {
  38. AppLog( "UIPromptWindow action : " + widget->GetId() + " was pressed ");
  39. UIWidget *someview = (UIWidget *)widget->GetView();
  40. UIPromptWindow *windowp = new UIPromptWindow(context_, someview, widget->GetId());
  41. SubscribeToEvent( windowp, E_UIPROMPTCOMPLETE, ATOMIC_HANDLER(PeriodicApp, HandlePromptCompleteEvent ));
  42. windowp->Show( "WindowTitle", "Message in window", "preset value", 0, 0, 0);
  43. }
  44. }
  45. }