Menu and button events


(Schlops) #1

Hi everyone!

Take a look at this code:


from Blender.Draw import *

tog = Create(1)
men = Create(1)

def gui():
	global tog, men
	tog = Toggle("Click_Me",1,30,10,100,18,tog.val)
	men = Menu("a | b| c| d| e| f", 2,30,40,100,18, men.val)

def event(evt, val):
	if (evt == ESCKEY and not val): Exit()

def bevent(evt):
	print "BUTTON:",evt

Register(gui, event, bevent)


If you select one item from the menu, there always occure two events: event “2” and event “4”. If you click and leave the menu w/o selecting, you get event “2” and “8”. This is very annoying if you have another button fiering event 4 or 8.
So here is my question: Are there any other “standard”-button-events?


(theeth) #2

Those aren’t really standard event. They are called to tell you what was the action done with the menu button. It will return the menu event number, and 4 or 8, depending on what the user did. As far as I know, those are the only event numbers that have a special meaning. You could skip them all the way, or use them to interact with the menu in a more precise way.

Martin