It is currently Tue Nov 19, 2019 2:25 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Select text / get selection for StringGadget/EditorGadge
PostPosted: Sun Sep 22, 2019 5:59 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 500
BarryG wrote:
Code:
SendMessage_(GadgetID(gadget),#EM_REPLACESEL,0,@text$)

But this doesn't let me press Ctrl+Z to undo the replace, like pasting does. What to do?

Try changing the 0 to 1.


Top
 Profile  
Reply with quote  
 Post subject: Re: Select text / get selection for StringGadget/EditorGadge
PostPosted: Sun Sep 22, 2019 8:10 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 393
wombats wrote:
Try changing the 0 to 1.

Thank you! :D


Top
 Profile  
Reply with quote  
 Post subject: Re: Select text / get selection for StringGadget/EditorGadge
PostPosted: Sat Oct 26, 2019 5:09 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 500
This is possible across Windows, macOS and GTK with API, but there isn't a way to set the selection (aside from selecting all of it) with QtScript on Qt. We can get the selection, however:
Code:
CompilerIf Subsystem("qt")
  Runtime Procedure OnSelectionChanged()
    Protected txt.s
    txt = QtScript("gadget(0).selectedText")
    SetGadgetText(1, txt)
  EndProcedure 
 
  If OpenWindow(0, 0, 0, 320, 100, "FrameGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    StringGadget(0, 10, 10, 300, 25, "hello")
    TextGadget(1, 10, 40, 300, 30, "")
    QtScript(~"gadget(0).selectionChanged.connect(function() { runtime.call(\"OnSelectionChanged()\"); })")   
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
CompilerElse
  MessageRequester("", "Qt subsystem required.")
CompilerEndIf

Having the ability to set/get the selection as part of PB would be great.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye