Quick Links: Download Gideros Studio | Gideros Documentation | Ultimate Guide | Gideros Development Center
Gideros UIKit Plugin API - Gideros Forum

Gideros UIKit Plugin API

MagnusviriMagnusviri Member
edited March 2012 in Plugins
I'm not sure where to put this so I started a new discussion. In an attempt to understand the UIKit plugin and how plugins in general work I complied what appears to me to be the current API (of sorts). Maybe we can put something like this somewhere (wiki?) so that it is current and accurate.

Gideros UIKit Plugin API

To use the plugin:

Copy uikit.mm to Xcode project "plugins" directory and then add to Xcode project.

In lua file:

require "ui"

-- perhaps do this?
stage:addEventListener(Event.ENTER_FRAME, function(event)


int hideStatusBar(bool show)
int addToRootView(view v)
int removeFromRootView(view v)
NSArray luaTableToArray(table t)

View : GEventDispatcherProxy
void addView(view childView)
void removeFromParent()
void setPosition(int x, int y)
void setSize(int width, int height)

Button : View
void setTitle(string title)
void setTitleColor(float r, float g, float b)
void setBGColor(float r, float g, float b)
void setFont(string fontname, float s)
void setImage(string imagefile)
void setBGImage(string imagefile)

Generated event: "onButtonClick"

Label : View
void setText(string text)
void setTextColor(float r, float g, float b)
void setBGColor(float r, float g, float b)
void setFont(string fontname, float s)

AlertView : GEventDispatcherProxy
new(string title, string message, string button)
void show()
void addButton(string title)

Generated event: "complete"

Switch : View
void setState(bool state)
bool getState()

Generated event: "onSwitchClick"

Slider : View
new(float min, float max)
void setValue(float value)
int getValue()
void setThumbImage(string imagefile)

Generated event: "onSliderChange"

TextField2 : View
void create(string text)
void setText(string text)
string getText()
void setTextColor(float r, float g, float b)
void setBGColor(float r, float g, float b)
void showKeyboard()

Generated events: "onTextFieldEdit", "onTextFieldReturn"

WebView : View
new(string url)
void loadLocalFile(string filename)

Generated events: "onWebViewNavigation"

PickerView : View
new(table items)
virtual int getRowCount()
virtual void setRow(int row)
virtual int getPickedRow()
virtual string getPickedItem()

Generated event: "onPickerRows"

Toolbar : View
void addButton()
void addTextButton(string caption)
void add(view xview)
//void setValue(float value)
//void setThumbImage(string imagefile)

Generated event: "onToolbarClick"

ScrollView : View
new(float x, float y, float w, float h, float cw, float ch)
void add(view v)

Generated event: onScrollViewClick

TableView : View
void setData(NSArray data) -- use luaTableToArray()
void setCellText(string text)
setPosition(x, y)
setSize(width, height)

Generated events: "cellForRowAtIndexPath", "didSelectRowAtIndexPath"
event table includes the additional field: "Row" (event.Row)


  • myspsmysps Member
    edited March 2012
    Oh, for me its a lot more understandable! thanks
    +1 -1
  • Mmmh :-?

    Seriously, I don't understand what you intention for your post is. Can someone explain this? Above I see Lua code, and then some kind of CPP code? But not really, so what is that?
    +1 -1
  • ar2rsawseenar2rsawseen Maintainer
    edited March 2012
    Call it a short documentation with list of possible methods and their arguments
    +1 -1
  • @MikeHart - it's the instructions on how to use it, with a list of the function headers available.

    Good idea, @Magnusviri - I'll include it in the github when I get a chance.
    +1 -1
  • Makes it simple for folks like me to know what it includes.

    +1 -1
  • Ahh ok, I thought it was all some kind of code because it was embedded inside the code tags.
    +1 -1
  • I updated the README - does that look OK? - sorry, I didn't credit you there - wasn't sure where to put it - let me know where you want it :)

    I left out the garbage collection - is that something that's necessary?
    +1 -1
  • @MikeHart, yeah I've never written API documentation before and I wasn't sure exactly what I should do with it. I suppose normal markup would've worked. And the weird style is mostly because I copied the code from uikit.mm and replaced obvious Cocoa/C++ code (replaced "NSString*" with "string").

    But I needed a list of what it could do, and in reality, when I posted this I wasn't even sure if I understood it enough that this was the list. So I do hope someone verifies that this is actually correct.

    And @Caroline, I put the call to collectgarbage() for every frame in it because it was in the uikit sample code. I didn't know if it was there because including uikit introduced issues that required using it every frame or not. @MikeHart, do you know if it is required?
    +1 -1
  • @Magnusviri It is not needed. It was a test to show off the GC problem I had before with the views that are added the scrollview. Thsi is not an issue anymore.
    Personally in my apps I collect garbadge in every frame because I don't want to deal with big hickups when the GC finally collects something. But everyone has their own opinion about this.
    +1 -1
  • Does anyone know if there is anything like this for gamekit?
    +1 -1
  • CarolineCaroline Guru
    edited March 2012
    Edit - Doh... You meant the api listing for gamekit...

    No, I don't think so.

    +1 -1
  • MagnusviriMagnusviri Member
    edited March 2012
    No I meant a list of commands. Or an example. There is a thread somewhere with some code and I have that bookmarked.

    Edit, yeah that. I will probably make a list then.
    +1 -1
  • ZoytZoyt Member
    Thanks Magnusviri!
    +1 -1
  • I want to thank @MikeHart for creating the plugin. I really like the MHUIKit API. It makes some things much easier than using the Cocoa API's. I think this could even be a good way to introduce people to Cocoa if they wanted to go that way. I'm not only convinced Gideros can make games now, I'm also thinking out what other projects I can do using Gideros. I might even start pushing this at my work where making iOS apps isn't a priority but could be extremely useful. Gideros lowers the barrier so much that I'm sensing lots of opportunities that just weren't there before.
    +1 -1
  • hai, I use MHUIKIT. i want to ask about set landscape for uikit.because i use orientation landscape in my application but every show ui from uikit orientation always potrait.
    what should i do?

    +1 -1
  • Thanks from me too... :)

    Makes the whole UI / Plugin thing a lot simpler to understand!

    +1 -1
Sign In or Register to comment.