[MAXGUI] Popmenu inside textarea possible
BlitzMax Forums/BlitzMax Beginners Area/[MAXGUI] Popmenu inside textarea possible| 
 | ||
| Hi! What I'm trying is creating a textbox where the user can select a text and then right-click anytime to get a popupmenu (like in the bmxgui). How can this be done? 
SuperStrict
Local  MyWindow:TGadget=CreateWindow("TextArea Example", 40,40,400,400)
Global MyText:TGadget=CreateTextArea(0,0,380,360,MyWindow)
Global popmenu:TGadget=CreateMenu("popup",0,Null)
CreateMenu("Load",101,popmenu)
CreateMenu("Save",102,popmenu)
AddTextAreaText(MyText,"The Quick Brown Fox ")
AddTextAreaText(MyText,"Jumps Over The Lazy Dog.")
Local cursorpos:Int
Local SelectedLength:Int
Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_GADGETSELECT
    cursorpos=TextAreaCursor(MyText)
    SelectedLength=TextAreaSelLen(MyText)
  Case EVENT_MOUSEDOWN
  If EventData()=2 PopupWindowMenu Mywindow,popmenu
  End Select
  SetStatusText MyWindow, "Text ="+TextAreaText(MyText,cursorpos,SelectedLength)
Forever
End
 | 
| 
 | ||
| 
Local  MyWindow:TGadget=CreateWindow("TextArea Example", 40,40,400,400)
Global MyText:TGadget=CreateTextArea(0,0,380,360,MyWindow)
Global popmenu:TGadget=CreateMenu("popup",0,Null)
CreateMenu("Load",101,popmenu)
CreateMenu("Save",102,popmenu)
AddTextAreaText(MyText,"The Quick Brown Fox ")
AddTextAreaText(MyText,"Jumps Over The Lazy Dog.")
Local cursorpos:Int
Local SelectedLength:Int
Repeat
  WaitEvent()
eventdi% = EventID()
Print eventdi
  Select eventdi
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_GADGETSELECT
    cursorpos=TextAreaCursor(MyText)
    SelectedLength=TextAreaSelLen(MyText)
  Case EVENT_GADGETMENU'8196
  	PopupWindowMenu Mywindow,popmenu
  End Select
  SetStatusText MyWindow, "Text ="+TextAreaText(MyText,cursorpos,SelectedLength)
Forever
End
Sry for the mess, but basicaly you need to use EVENT_GADGETMENU. | 
| 
 | ||
| Thank you. That what was I was searching for. |