How can CheckEvent() Fail?

Discuss any general programming issues here
Bugala
Posts: 1181
Joined: Sun Feb 14, 2010 7:11 pm

Re: How can CheckEvent() Fail?

Post by Bugala »

Okay. thanks a lot. Now i know how to fix the code.

Didnt really want to touch it until I knew what the actual problem was.


So Andreas, what about that possibility to add some extra info to button?

In way that there could be called something like self.type for example.

So that it could be used in way of:

Code: Select all

function buttonfunctions(msg)

switch msg.action
   case OnMouseOver:
     Switch self.type
        case 1:
           code
        case 2:
           code
      endswitch
endswitch
endfunction
I did figure out some outside way to get info in there.

That when you make the button you could be keeping table of buttontypes, and then keep changing their type and call it inside a function.

ie.

Code: Select all

function buttonfunctions(msg)
type = currentbuttons[msg.id]
...
endfunction

evttable={OnMouseOver=buttonfunctions()}
currentbuttons={}
makebutton(1... evttable)
makebutton(2... evttable)
currentbuttons[1] = 1
currentbuttons[2] = 0

WaitEvent()
User avatar
airsoftsoftwair
Posts: 5446
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How can CheckEvent() Fail?

Post by airsoftsoftwair »

Okay. thanks a lot. Now i know how to fix the code.
Didnt really want to touch it until I knew what the actual problem was.
So Andreas, what about that possibility to add some extra info to button?
It's possible by using the "userdata" argument when creating the button using MakeButton(). You can simply pass a table as user data and then store any information you need into it. It will always be passed to your callback.
Bugala
Posts: 1181
Joined: Sun Feb 14, 2010 7:11 pm

Re: How can CheckEvent() Fail?

Post by Bugala »

Ah, thanks. Didnt realise that.

Should have read manual on MakeButton better.
Post Reply