The following illustrates extending a TProxyGadget which allows you to override any TGadget method while maintaining platform neutrality (you don't care if you are extending a TWin32Gadget or a TFLTKGadget).
Hmm, EventGadgetSource() should be the proxy, so a little more work required here sorry...
Strict Type TMyTextArea Extends TProxyGadget Field textarea:TGadget Method Create:TMyTextArea(x,y,w,h,group:TGadget,style=0) textarea=CreateTextArea(x,y,w,h,group,style) SetProxy textarea Return Self End Method ' and a quick override to make sure the proxy is working... Method SetText(text$) textarea.SetText ("***"+text+"***") End Method End Type ' and a matching public constructor function Function CreateMyTextArea:TMyTextArea(x,y,w,h,group:TGadget) Return New TMyTextArea.Create(x,y,w,h,group) End Function ' and a modified createmytextarea.bmx test program.... Local window:TGadget Local textarea:TGadget window=CreateWindow("My Window",130,20,200,200,0,15|WINDOW_ACCEPTFILES) textarea=CreateMyTextArea(0,0,ClientWidth(window),ClientHeight(window)/2,window) SetGadgetLayout textarea,1,1,1,1 SetGadgetText textarea,"a textarea gadget~none line~nandanother" ActivateGadget textarea SelectTextAreaText textarea,1,1,TEXTAREA_LINES Print TextAreaCursor(textarea,TEXTAREA_LINES) Print TextAreaSelLen(textarea,TEXTAREA_LINES) While WaitEvent() Print CurrentEvent.ToString()+" "+EventSourceHandle() Select EventID() Case EVENT_WINDOWCLOSE End Case EVENT_APPTERMINATE End End Select Wend
Hmm, EventGadgetSource() should be the proxy, so a little more work required here sorry...