EVENT_MOUSEUP ... Canvas

BlitzMax Forums/MaxGUI Module/EVENT_MOUSEUP ... Canvas

Bobysait(Posted 2007) [#1]
I try to make a "PopupWindowMenu" when right clicking the window, but if I use a GraphicsCanvas, MouseEvents are locked on the canvas, and I can't get events anymore from panels.

Local win:TGadget=CreateWindow("MouseTest",5,5,800,600)
Local gad:TGadget=CreatePanel(5,5,790,520,win)

can:TGadget		=	CreateCanvas(5,80,780,400,gad)

popup:TGadget=	CreateMenu("coucou",0,Null)
				CreateMenu("choix 1 ",1,popup)
				CreateMenu("choix 2 ",2,popup)

SetGraphics CanvasGraphics(can)
Cls;Flip

While True
	WaitEvent
	Select CurrentEvent.ID
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_MOUSEUP
			Cls;DrawText "data:"+String(EventData()),200,200;Flip 1
			PopupWindowMenu(win,popup)
	End Select
Wend
End


Is there something missing ?
Is that SetGraphics halt every mouse events outside the graphics specified ?

Anyway to get a popupmenu drawn under mouse position ?


DavidDC(Posted 2007) [#2]
Is this what you wanted?

Local win:TGadget=CreateWindow("MouseTest",5,5,800,600)
Local gad:TGadget=CreatePanel(5,5,790,520,win,PANEL_ACTIVE)

can:TGadget		=	CreateCanvas(5,80,780,400,gad)

popup:TGadget=	CreateMenu("coucou",0,Null)
				CreateMenu("choix 1 ",1,popup)
				CreateMenu("choix 2 ",2,popup)
While True
	WaitEvent
	Select CurrentEvent.ID
		Case EVENT_GADGETPAINT
			SetGraphics CanvasGraphics(can)
			Cls
			DrawText "data:"+String(EventData()),200,200
			Flip 1	
		Case EVENT_WINDOWCLOSE
			End
		Case EVENT_MOUSEDOWN
			RedrawGadget(can)
		Case EVENT_MOUSEUP		
			PopupWindowMenu(win,popup)
	End Select
Wend
End


- David


Bobysait(Posted 2007) [#3]
I'll test, but for now, i found what i was looking for, using "EVENT_GADGETMENU"

All I wanted was a context menu on right click , for editing/deleting/etcing... tree listes, or text field :)

[edit]

here is what i expected
Local win:TGadget		=	CreateWindow("MouseTest",5,5,800,600)
Local gad:TGadget		=	CreatePanel(5,5,790,580,win)

Local winmenu:TGadget	=	CreateMenu	("Menu",0,WindowMenu(win))
							CreateMenu	("Close",1,winmenu)
							CreateMenu	("",0,winmenu)
							CreateMenu	("Delete current Object",2,winmenu)
							CreateMenu	("Add a new Object",3,winmenu)
							CreateMenu	("Insert Object",4,winmenu)
							CreateMenu	("OverWrite Object",4,winmenu)
							UpdateWindowMenu(win)

Local can:TGadget		=	CreateCanvas(5,80,780,400,gad)

Local Popup:TGadget		=	CreateMenu("default",0,Null)
							CreateMenu("Close !",1,Popup)

Local popupL:TGadget	=	CreateMenu("ListMenu",0,Null)
							CreateMenu("Delete",2,popupL)

Local popupT:TGadget	=	CreateMenu("TextMenu",0,Null)
							CreateMenu("Add",3,popupT)
							CreateMenu("Insert",4,popupT)
							CreateMenu("OverWrite",5,popupT)

Local ListBox:TGadget	=	CreateListBox(10,10,200,50,gad,0)
							AddGadgetItem(ListBox,"Liste item 1")
							AddGadgetItem(ListBox,"Liste item 2")
							AddGadgetItem(ListBox,"Liste item 3")

Local textArea:TGadget	=	CreateTextArea(220,10,300,50,gad,0)

SetGraphics CanvasGraphics(can)
Cls;Flip
Local Index:Int=0
Local AreaText:String=""

While True
	WaitEvent
	Local Id:Int=CurrentEvent.ID
	Select Id
		Case EVENT_WINDOWCLOSE	;	End
		Case EVENT_GADGETPAINT	;	SetGraphics CanvasGraphics(can);Cls;Flip 1	
		Case EVENT_MOUSEDOWN	;	RedrawGadget(can)
		' Popup when mouseDown .... not working
		Case EVENT_MOUSEUP		;	PopupWindowMenu(win,Popup)
		' Update listBox selection
		Case EVENT_GADGETSELECT
			Select EventSource()
				Case ListBox	;	Index=CurrentEvent.data
			End Select
		' popup edit gadget
		Case EVENT_GADGETMENU
			Local GadSrc:TGadget=TGadget(CurrentEvent.Source)
			Select GadSrc
				Case textArea	;	PopupWindowMenu win,popupT
				Case ListBox	;	PopupWindowMenu win,popupL;Index=CurrentEvent.data
				Default
			End Select
		' select menu action to perform
		Case EVENT_MENUACTION
			Select CurrentEvent.data
				Case 1 ' default ...
					End
				Case 2 ' Delete liste Object
					RemoveGadgetItem(ListBox,Index)
				Case 3 ' Add at end of list
					AreaText=TextAreaText (textArea)
					If Len(AreaText)>0	AddGadgetItem(ListBox,AreaText)
				Case 4 ' Insert Texte at the cursor position in the List
					AreaText=TextAreaText (textArea)
					If Len(AreaText)>0	InsertGadgetItem(ListBox,Index,AreaText)
				Case 5 ' Overwrite current texte in the liste
					AreaText=TextAreaText (textArea)
					If Len(AreaText)>0	ModifyGadgetItem(ListBox,Index,AreaText)
			End Select
	End Select
Wend
End


I tryed your code, it works fine. but I can't get it to work in my own code :/

hav I made a mistake with redrawgadget ?


DavidDC(Posted 2007) [#4]
Perhaps here then.


Bobysait(Posted 2007) [#5]
many Thanks, i have a look at your link.

ps : I Updated my post ( the second one )


Bobysait(Posted 2007) [#6]
Ok... now I see my mistake...
=> panel must be created with "PANEL_ACTIVE" flag.