Worlds/Era iPhone/Scrolling: Difference between revisions
From Graal Bible
m (moved Worlds/Era iPhone/gui scroll to Worlds/Era iPhone/Scrolling: looks stupid since the underscore is replaced with a space.) |
No edit summary |
||
Line 5: | Line 5: | ||
keymod, mx, my, clicks, mouseNumber | keymod, mx, my, clicks, mouseNumber | ||
The event is called | The event is called on the object specified in the 'scroll.callObject' variable. | ||
== Optimization for Lists == | == Optimization for Lists == |
Latest revision as of 15:03, 23 December 2009
The class gui_scroll lets you create a GuiScrollCtrl with iPhone-like scrolling. For PC users, it displays a scroll bar, but for iPhone users, they can manipulate it just like a native control.
Receiving Mouse Events
Specify a "clickEvent" variable, with a value such as "onMyScrollClicked", and it will be called when the user clicks, with the parameters:
keymod, mx, my, clicks, mouseNumber
The event is called on the object specified in the 'scroll.callObject' variable.
Optimization for Lists
For simplicity, it's easy to create lists without coding your own row detection for clicks. Set 'scroll.list' to the GuiTextListCtrl object you create, and it will automagically function. See the example below.
Example
//#CLIENTSIDE function onCreated() { new GuiWindowCtrl("iPhoneTest_Window") { profile = iPhoneWindowProfile; width = 300; height = 300; clientRelative = visible = true; canMinimize = canClose = canMaximize = canResize = false; text = "iPhone Window"; new GuiScrollCtrl("iPhoneTest_Scroll") { profile = iPhoneScrollProfile; x = 0; y = 0; width = iPhoneTest_Window.width - 30; height = iPhoneTest_Window.height - 32; this.join("gui_scroll"); temp.scroll = this; new GuiTextListCtrl("iPhoneTest_List") { profile = iPhoneTextListProfile; x = 0; y = 0; this.clearRows(); // fill it with crap for (temp.i = 0; i < 100; i ++) { this.addRow(0, "Item " @ (i + 1)); c ++; } scroll.list = this; } } } }