Copy Paste gadget editor

Just starting out? Need help? Post your questions and find answers here.
andrey2023
New User
New User
Posts: 7
Joined: Mon Mar 06, 2023 5:55 am

Copy Paste gadget editor

Post by andrey2023 »

How to read and write selected text to clipboard? (Copy Paste)
For example in the Editor gadget?
User avatar
jacdelad
Addict
Addict
Posts: 2029
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Copy Paste gadget editor

Post by jacdelad »

Code: Select all

SetGadgetText(#MyEditor,GetClipboardText())
SetClipboardText(GetGadgetText(#MyEditor))
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
andrey2023
New User
New User
Posts: 7
Joined: Mon Mar 06, 2023 5:55 am

Re: Copy Paste gadget editor

Post by andrey2023 »

need highlighted text
User avatar
jacdelad
Addict
Addict
Posts: 2029
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Copy Paste gadget editor

Post by jacdelad »

Sorry, I overhead the "selected".

Windows:

Code: Select all

Define start.l.end.l
Sendmessage_(GadgetID(#MyEditor),#EM_GETSEL,@start,@end)
SetClipboardText(Mid(GetGadgetText(#MyEditor),start+1,end-start))
Typed on my phone, hope it's correct.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
andrey2023
New User
New User
Posts: 7
Joined: Mon Mar 06, 2023 5:55 am

Re: Copy Paste gadget editor

Post by andrey2023 »

and under linux?
User avatar
jacdelad
Addict
Addict
Posts: 2029
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Copy Paste gadget editor

Post by jacdelad »

andrey2023 wrote: Tue Aug 22, 2023 3:54 pm and under linux?
Under Linux you need a different approach. :wink:
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 562
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: Copy Paste gadget editor

Post by Sicro »

andrey2023 wrote: Tue Aug 22, 2023 3:54 pm and under linux?
It is always an advantage to specify in your initial question for which operating system you are looking for a solution.

Here is a sample code for Linux:
http://www.chabba.de/Linux/EditorGadget ... Command.pb
  • Select text in the EditorGadget and press the left button at the top to copy the selected text to the clipboard.
  • Select text in the EditorGadget and press the middle button at the top to cut out the selected text and copy it to the clipboard.
  • Place the text cursor anywhere in the text of the EditorGadget and press the top right button to paste the text from the clipboard to the position of the text cursor.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Post Reply