BsGUITreeViewEditBox.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "BsGUITreeViewEditBox.h"
  2. #include "BsGUICommandEvent.h"
  3. #include "BsGUIWidget.h"
  4. #include "BsGUISkin.h"
  5. using namespace CamelotFramework;
  6. using namespace BansheeEngine;
  7. namespace BansheeEditor
  8. {
  9. const CM::String& GUITreeViewEditBox::getGUITypeName()
  10. {
  11. static String name = "TreeViewEditBox";
  12. return name;
  13. }
  14. GUITreeViewEditBox* GUITreeViewEditBox::create(BS::GUIWidget& parent, const BS::GUIElementStyle* style)
  15. {
  16. if(style == nullptr)
  17. {
  18. const GUISkin& skin = parent.getSkin();
  19. style = skin.getStyle(getGUITypeName());
  20. }
  21. return new (cm_alloc<GUITreeViewEditBox, PoolAlloc>()) GUITreeViewEditBox(parent, style, GUILayoutOptions::create(style));
  22. }
  23. GUITreeViewEditBox* GUITreeViewEditBox::create(BS::GUIWidget& parent, const BS::GUIOptions& layoutOptions, const BS::GUIElementStyle* style)
  24. {
  25. if(style == nullptr)
  26. {
  27. const GUISkin& skin = parent.getSkin();
  28. style = skin.getStyle(getGUITypeName());
  29. }
  30. return new (cm_alloc<GUITreeViewEditBox, PoolAlloc>()) GUITreeViewEditBox(parent, style, GUILayoutOptions::create(layoutOptions, style));
  31. }
  32. GUITreeViewEditBox::GUITreeViewEditBox(BS::GUIWidget& parent, const BS::GUIElementStyle* style, const BS::GUILayoutOptions& layoutOptions)
  33. :GUIInputBox(parent, style, layoutOptions, false)
  34. {
  35. }
  36. bool GUITreeViewEditBox::commandEvent(const BS::GUICommandEvent& ev)
  37. {
  38. bool processed = GUIInputBox::commandEvent(ev);
  39. if(ev.getType() == GUICommandEventType::Return)
  40. {
  41. if(!onInputConfirmed.empty())
  42. onInputConfirmed();
  43. return true;
  44. }
  45. else if(ev.getType() == GUICommandEventType::Escape)
  46. {
  47. if(!onInputCanceled.empty())
  48. onInputCanceled();
  49. return true;
  50. }
  51. else if(ev.getType() == GUICommandEventType::FocusLost)
  52. {
  53. if(!onInputCanceled.empty())
  54. onInputCanceled();
  55. return true;
  56. }
  57. return processed;
  58. }
  59. };