Super basic question on using UI module/package/library

Hi
I’m brand spankin’ new to Corona and Lua and I’m studying all of the Sample Apps. Many years ago I took a course in Java, so I’m familiar with creating an object and how to use properties of that object. It seems Lua follows the same concept- though it’s not an object-oriented language. I have a question about the Analytics app which uses UI module/package/library, for example:

local button1 = ui.newButton{
default = “buttonBlue.png”,
over = “buttonBlueOver.png”,
onRelease = buttonRelease1,
text = “Log Event 1”
}

  1. Where in the API reference can I read about the properties of UI? How would I know newButton has the properties of default, over, onRelease, text?

  2. And is UI thought of as a package, module, or library?

Thanks! [import]uid: 45656 topic_id: 9519 reply_id: 309519[/import]

As far as I know ui.lua isnt part of the main corona sdk but it more of a user extension. i.e. the source code is open, and required in your folder to use it.
I’d check the source for param names, but there is a thread either on the forums or the code exchange on its usage.
I would call it a module containing classes, but i havent had a good look at it. All I remember is it creates useful button objects :slight_smile:

It really needs to be better documented for newbies, I had the same probs as you when I started [import]uid: 34945 topic_id: 9519 reply_id: 34790[/import]

Thank you for your help! This is brand new territory so I’ll be asking a lot questions. I’ll probably pay for the individual developer support because I don’t want to beat my brains as I need to focus on developing an app.

I’ll check the other threads to see where is the best place to post my questions. I don’t want to upset anyone if I’m in the wrong forum. :slight_smile: [import]uid: 45656 topic_id: 9519 reply_id: 34920[/import]

buy me a subscription while you’re at it :wink:
you will find the corona sdk is probably the easiest programming language out there. If you have programmed before, you will pick it up no problem.
These forums are a great source, if you get stuck with the docs, if you post on the newbie forum everyone is more than willing to help you succeed. Even questions you might be scared of looking silly asking, we were all new at one stage, I for example have been using corona for about 20 hours with a PHP background, and now I spend more time helping people than asking questions myself. I’m writing my own modules (I’ve got a particle effects module in a post on here that really needs updating)
I love corona :slight_smile: [import]uid: 34945 topic_id: 9519 reply_id: 34934[/import]

I was programmer of Microsoft technologies…Eeek! :slight_smile:

I have a basic understanding of objects but it’s just trying to put it all together and think in a different way than what I was trained to do.

I welcome your help in the future.

Take care! [import]uid: 45656 topic_id: 9519 reply_id: 34950[/import]

I was a programmer using Microsoft tools…Eeek…I’m coming from the dark side. :slight_smile:

I have a basic understanding of objects and it’s just trying to get my brain to think in a different way then what it was trained to do.

I welcome your help in the future!

Take care! [import]uid: 45656 topic_id: 9519 reply_id: 34951[/import]

Once you get your head around the fact that objects are represented by associative arrays (‘tables’), and functions can be array variables, it makes a lot more sense :slight_smile:

For ex,
[lua]prettyPicture = display.newImage(‘bella.png’,200,200); --optional ;
prettyPicture.newVar = ‘Storing this string in the image object’
prettyPicture:newFunc = function() return self.newVar end --storing a function[/lua]

Btw, in case you hadn’t come across object:function, it just provides a self reference for the function, make sure you don’t fall into the trap of forgetting its there if you use extra params ie

[lua]function foo:bar(a,b)
print(a)
print(b)
end

foo:bar(‘a’,‘b’)

–‘table 0x0000000’
–‘a’[/lua]

I havent tested any of that, so if its wrong, someone please point it out :wink:
[import]uid: 34945 topic_id: 9519 reply_id: 35004[/import]

Functions as array variables?? Wow…I’ve got a lot to learn.

What editor do you use? Do you use and IDE? If so, which one?

Many thanks in advance! [import]uid: 45656 topic_id: 9519 reply_id: 35007[/import]

I use notepad++ which is a free opensource editor with full syntax highlighting
No IDE, and i haven’t even tried the new console debugger :slight_smile:
I just use the console window, and frequent refreshes of the simulator window

Its pretty straightfoward, with a browser window open to the docs I haven’t had much trouble.

A handy bit of code is the table.show function, google ‘lua table.show’, which allows you to output table contents to the console [import]uid: 34945 topic_id: 9519 reply_id: 35015[/import]