Advertisement
Guest User

Mudlet Geyser HBox/VBox Demo

a guest
Jan 23rd, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.78 KB | None | 0 0
  1. button_vBox = Geyser.VBox({
  2.   -- Vertical box to hold buttons in.
  3.   -- This vertical box will automatically do two things:
  4.   --    (1) Set size of buttons so that they are uniform.
  5.   --    (2) Position buttons so that they look the way that you want them to.
  6.  
  7.   name = "button_vBox",
  8.   x = 0, y = 0,         -- Set x and y to actual position. These two coordinates control position of entire group.
  9.   width = 300, height = 300,    -- Set height/width to desired size. These two sizes control size of entire group.
  10. })
  11.  
  12. -- Top row --
  13. button_1 = Geyser.Label({
  14.   -- Top button, per your diagram.
  15.  
  16.   name      = "button_1",
  17.   fgColor   = "black",
  18.   color     = "red",
  19.   width     = "100%",
  20.   message   = [[<center>Button 1</center>]]
  21. }, button_vBox) -- Last argument of this line sets this object as child of button_vBox.
  22.  
  23. button_1:setClickCallback("function_button_1")
  24. -- End top row --
  25.  
  26. -- Second row --
  27. button_hBox_top = Geyser.HBox({
  28.   -- A horizontal box. See size/position comments above under button_vBox.
  29.   --
  30.   -- This box will be underneath button_1.
  31.   -- This box will be a child of button_vBox.
  32.   -- This box will hold button_2 and button_3, which will each take half the width of button_hBox_top.
  33.  
  34.   name      = "button_hBox_top",
  35.   width     = "100%",
  36. }, button_vBox) -- Child of button_vBox
  37.  
  38. button_2 = Geyser.Label({
  39.   -- Button 2.
  40.   -- Child of button_hBox_top.
  41.   -- Is on the left.
  42.  
  43.   name      = "button_2",
  44.   fgColor   = "white",
  45.   color     = "orange",
  46.   message   = [[<center>Button 2</center>]]
  47. }, button_hBox_top) -- Child of button_hBox_top
  48.  
  49. button_2:setClickCallback("function_button_2")
  50.  
  51. button_3 = Geyser.Label({
  52.   -- Button 3.
  53.   -- Child of button_hBox_top.
  54.   -- Is on the right.
  55.  
  56.   name      = "button_3",
  57.   fgColor   = "black",
  58.   color     = "yellow",
  59.   message   = [[<center>Button 3</center>]]
  60. }, button_hBox_top) -- Child of button_hBox_top
  61.  
  62. button_3:setClickCallback("function_button_3")
  63. -- End second row--
  64.  
  65. -- Third row --
  66. button_hBox_bottom = Geyser.HBox({
  67.   -- A horizontal box. See size/position comments above under button_vBox.
  68.   --
  69.   -- Underneath button_2 and button_3 (which are actually inside the invisible button_hBox_top)
  70.   -- Will hold button_4 and button_5.
  71.  
  72.   name = "button_hBox_bottom",
  73.   width = "100%",
  74. }, button_vBox) -- Child of button_vBox
  75.  
  76. button_4 = Geyser.Label({
  77.   -- Button 4.
  78.   -- Child of button_hBox_bottom.
  79.   -- Is on the left.
  80.  
  81.   name      = "button_4",
  82.   fgColor   = "white",
  83.   color     = "green",
  84.   message   = [[<center>Button 4</center>]]
  85. }, button_hBox_bottom) -- Child of button_hBox_bottom
  86.  
  87. button_4:setClickCallback("function_button_4")
  88.  
  89. button_5 = Geyser.Label({
  90.   -- Button 5.
  91.   -- Child of button_hBox_bottom.
  92.   -- Is on the right.
  93.  
  94.   name      = "button_5",
  95.   fgColor   = "white",
  96.   color     = "blue",
  97.   message   = [[<center>Button 5</center>]]
  98. }, button_hBox_bottom) -- Child of button_hBox_bottom
  99.  
  100. button_5:setClickCallback("function_button_5")
  101. -- End third row --
  102.  
  103. -- Fourth (final) row --
  104. button_6 = Geyser.Label({
  105.   -- Button 6.
  106.   -- Bottom row.
  107.   -- Just like Button 1, spans entire width of button_vBox.
  108.  
  109.   name      = "button_6",
  110.   width     = "100%",
  111.   fgColor   = "white",
  112.   color     = "purple",
  113.   message   = [[<center>Button 6</center>]]
  114. }, button_vBox) -- Child of button_vBox
  115.  
  116. button_6:setClickCallback("function_button_6")
  117. -- End fourth row.
  118.  
  119. -- Begin function declarations.
  120. function function_button_1()
  121.   doSomething(1)
  122. end
  123.  
  124. function function_button_2()
  125.   doSomething(2)
  126. end
  127.  
  128. function function_button_3()
  129.   doSomething(3)
  130. end
  131.  
  132. function function_button_4()
  133.   doSomething(4)
  134. end
  135.  
  136. function function_button_5()
  137.   doSomething(5)
  138. end
  139.  
  140. function function_button_6()
  141.   doSomething(6)
  142. end
  143.  
  144. function doSomething( button_number )
  145.   echo("\nYou pressed button number " .. button_number .. "!\n")
  146. end
  147. -- End function declarations.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement