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 ?
|