Old 01-13-2010, 11:26 PM
ThievingSix ThievingSix is offline
Join Date: Aug 2008
Posts: 218
Default Apeopex GUI/Event Module

I promised it earlier but finally got around to working on it. What this is, is a module you include in your application to allow event driven GUI code.

For example:
  Small application to demonstrate the Apeopex module.
  Displays two buttons, one 3D and one flat. 

--Clear cached package
package.loaded.Apeopex = nil;
--Load Apoepex module
require "Apeopex";

--Set Exit variable
DoExit = false;

--Our button event functions. Simply sets our Exit variable to true.
function ExitApp()
  DoExit = true;

function DisplayText()
  text.draw(10,150,"You pressed the second button!");

function TouchEvent(x,y)
  text.draw(200,10,"X: " .. x);
  text.draw(200,30,"Y: " .. y);

--Demonstrates screen wrapper and module color usage

Apeopex.CreateButton(10,50,100,30,false,Apeopex.clLightGray,Apeopex.clBlack,"Display Text",DisplayText);

--Demonstrate event usage
Apeopex.OnHomeHold = ExitApp;
Apeopex.OnTouchClick = TouchEvent;
Apeopex.OnTouchMove = TouchEvent;

--Our application loop
  --Call the module event loop to process button clicks
  --Exit when button is pressed, which calls the event ExitApp, which sets DoExit to true.
until (DoExit == true);
Right now there is only support for simple buttons, but I wanted to get it out there to see what you think . If I had a camera I'd attempt to get a picture of the buttons, but they are slightly 3Dish and are push/rollover buttons that utilize the touch.down() and touch.up() events.

v0.1 - Release!
v0.2 - Fully event driven. Allowed to add user events for all control events. Works without sleep or wait.
Attached Files
File Type: zip Apeopex(Module + Sample).zip (3.5 KB, 22 views)
File Type: zip Apeopex(Module + Sample) (4.2 KB, 49 views)

Last edited by ThievingSix; 01-15-2010 at 12:44 PM.
Reply With Quote

Advertisement [Remove Advertisement]

Old 01-14-2010, 03:33 AM
Jan_DK's Avatar
Jan_DK Jan_DK is offline
Junior Member
Join Date: Mar 2009
Location: Denmark
Posts: 88

Nice, I'm playing with it as you can see :-)

But I have a slight problem if I pass parms. to the function from the line below.

function Drawplanet(refx,refy)

Apeopex.CreateButton(10,90,100,30,false, LightGray,Apeopex.clBlack,"Draw planet ",Drawplanet(200,120));

It draws the planet before drawing the button or touching the button, and the button never work again.

If I use:
function Drawplanet()

Apeopex.CreateButton(10,90,100,30,false, LightGray,Apeopex.clBlack,"Draw planet ",Drawplanet );

And put the parms in the function then everything is fine, is this behaviour intended ?

EDIT: the complete code

Reply With Quote

Old 01-14-2010, 10:45 AM
ThievingSix ThievingSix is offline
Join Date: Aug 2008
Posts: 218

In a sense, yes, it's intended.

When passing a function with just the function name(eg "DrawPlanet") you are passing the actual function address. When passing a function with parameters(eg "Drawplanet(200,120)") you are telling lua to call that function before CreateButton and pass the result of the function to CreateButton. It's evaluating it as a function you want to pass the result of instead of passing the actual function itself.

What you could do is add another parameter to the end of CreateButton() that will take the parameters you want to pass to the event but since LUA deals with global variable access equally or better than function parameter passing overhead I decided to go this route.

BTW, nice planet draw =D.
Reply With Quote

Old 01-15-2010, 12:35 PM
ThievingSix ThievingSix is offline
Join Date: Aug 2008
Posts: 218

Updated, sample works without a sleep or wait. Might have to do with the way I'm handling events.
Reply With Quote

Old 05-08-2010, 09:16 AM
Donone Donone is offline
Junior Member
Join Date: May 2010
Posts: 59
Default Slight edit needed

I believe that Apeopex needs a slight edit (not being critical in any way).
FillScreen (and anywhere else they are used) requires width and height to both have '-1' appended. 0 to 239=240 etc.
Reply With Quote

Old 05-10-2010, 06:24 AM
Donone Donone is offline
Junior Member
Join Date: May 2010
Posts: 59

I have been experimenting to learn how this package works.
Can you please explain why the function ExitApp() cannot be placed in Apeopex itself. I have tried to do that and it does not work.

My expectancy was that the package would have been declared? as it is loaded and therefore the function will have been pre-declared.

I have obviously not understood packages correctly.
Thank you.
Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 01:20 AM.