Time for more source.

26Jun05

Looks like I’m at it again. After taking a few weeks off I’ve decided to start developing new software for the Hiptop. I have put a lot of work into some new programs and hope to release something in the next week or two. While I was at it (thanks to jgeorge at least) I put together a short piece of source code to help illustrate how to setup an event that fires depends on what object calls the event.

Sample Code
As you can see by the file name that one of the projects that I’m working on is/was named wordfind though.To begin with when you first setup the object (button object based off LetterButton in our example) and add the event code you add a few extra statements.

theButton[0].setEvent(this,kEvent,0,null); 

For setEvent I’ve declared that this will be looking for the event, kEvent will be the name of the event, 0 will be the Int value passed with the event, and null will be essentially nothing and not covered in this brief code today. For now though just know that you won’t need to put anything there.

public boolean receiveEvent(Event e) {
switch (e.type) {
case kEvent:
TextInputAlertWindow theAlert = new TextInputAlertWindow(2,theButton[e.data].getLetter(),true); 

Once I’ve called the receiveEvent handler (which will handle the event generated declared as e) it filters down to the kEvent case, and then begins to work it’s magic. In this instance it uses e.data to extract the int from our setEvent to create a TextInputAlertWindow with the text received from theButton[e.data].getLetter().

Simple as that for using one event to generate different effects when called from different locations. Usually used when you have an Array of objects and would like to have the same actions occur but based off different values.

Hope this helps anyone out there, and if you have any source you’d like to share with the community please contact me I’d love to host it.

Advertisements


No Responses Yet to “Time for more source.”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: