Posts: 102
Threads: 30
Joined: Mar 2018
02-15-2019, 04:04 AM
(This post was last modified: 02-15-2019, 04:06 AM by InterestedNewbie.)
How do I cut and paste only the
selected text from a dialog edit field? And not all text like in this section of my script (where e3 is the edit field, case 4 and 5 cut-and-paste all text but case 6 is supposed to cut and paste
only the text that was
selected):
str controls = "3"
str e3
;g1
int r=ShowDialog(dd &sub.DlgProc &controls)
;
sel r
,case 4
,if(!empty(e3))
,,paste e3
,case 5
,if(!empty(e3))
,,paste e3
,,e3.all
,,,,key V ;; Space
,,goto g1
,case 6
,,,,,
,ret
Posts: 1,337
Threads: 61
Joined: Jul 2006
read qm help getsel
http://www.quickmacros.com/help/str/IDP_S_CLIP.html
basic example will get selected text
int c=id(3 hDlg) ;;editable text
str s.getsel(0 0 c)
out s
read more about cut options in help
Posts: 102
Threads: 30
Joined: Mar 2018
Thanks Kevin, yes I already read that section but inserting this into the script gives unknown identifier error with hDlg:
case 6
,,,int c=id(3 hDlg) ;;editable text
str s.getsel(0 0 c)
out s
Posts: 1,337
Threads: 61
Joined: Jul 2006
The error is because hDlg is only known inside the dialog. You will need to get the selected text before the dialog closes.
Posts: 102
Threads: 30
Joined: Mar 2018
I see. Okay I will edit the code accordingly.
Thanks!