code_uibutton.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // UIButton application source code
  2. using System;
  3. using AtomicEngine;
  4. public class code_uibutton : CSComponent {
  5. public void Setup( UIWidget layout )
  6. {
  7. var dest = new AtomicEngine.Vector<AtomicEngine.UIWidget>();
  8. layout.SearchWidgetClass( "TBButton", dest );
  9. for (var ii = 0; ii < dest.Size; ii++) { // set bulk event handlers on all buttons -- boom!
  10. dest[ii].SubscribeToEvent<WidgetEvent> (dest [ii], HandleUibuttonEvent );
  11. }
  12. }
  13. private static void HandleUibuttonEvent( WidgetEvent ev )
  14. {
  15. UIWidget widget = (UIWidget)ev.Target;
  16. if ( widget.Equals(null)) return;
  17. if ( ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) {
  18. if (widget.GetId() == "uibuttoncode" ) {
  19. AtomicMain.AppLog( "UIButton support : " + widget.GetId() + " was pressed " );
  20. AtomicMain.ViewCode ( "Components/code_uibutton.cs", widget.GetParent() );
  21. }
  22. if (widget.GetId() == "uibuttonlayout" ) {
  23. AtomicMain.AppLog( "UIButton support : " + widget.GetId() + " was pressed ");
  24. AtomicMain.ViewCode ( "Scenes/layout_uibutton.ui.txt", widget.GetParent() );
  25. }
  26. if (widget.GetId() == "demobutton" ) {
  27. AtomicMain.AppLog( "UIButton action : " + widget.GetId() + " was pressed ");
  28. }
  29. if (widget.GetId() == "buttonducky" ) {
  30. AtomicMain.AppLog( "UIButton action : " + widget.GetId() + " was pressed ");
  31. }
  32. if (widget.GetId() == "buttonready" ) {
  33. AtomicMain.AppLog( "UIButton action : " + widget.GetId() + " was pressed ");
  34. }
  35. if (widget.GetId() == "buttonatomic" ) {
  36. AtomicMain.AppLog( "UIButton action : " + widget.GetId() + " was pressed ");
  37. }
  38. if (widget.GetId() == "buttongreen" ) {
  39. AtomicMain.AppLog( "UIButton action : " + widget.GetId() + " was pressed ");
  40. }
  41. }
  42. }
  43. }