Hi,
There was a post about this, way back in 2005, on a German forum, but it involved an api workaround.
I'll jump to the Win api if need be, but was wondering if PB has been given native support, specifically for highlighting and COPYING, from an EditorGadget, to elsewhere. Or is there a more direct way, than the 2005 suggestion
(
Procedure Editor_GetSelLength (gadget)
sel.CHARRANGE
SendMessage_ (GadgetID (gadget), $ 0434.0, @ sel)
ProcedureReturn sel \ cpMax - sel \ cpMin
EndProcedure
Procedure.s Editor_GetSelText (gadget)
Text.s = Space (Editor_GetSelLength (Gadget) + 1 )
SendMessage_ (GadgetID (gadget), $ 043E, 0, @ Text.s)
ProcedureReturn Text.s
EndProcedure SetClipboardText (Editor_GetSelText (gadget))
)
?
Copying & Pasting from an EditorGadget
-
- User
- Posts: 59
- Joined: Sun Jul 21, 2013 8:30 am
Re: Copying & Pasting from an EditorGadget
Cut, Copy & Paste
Code: Select all
Enumeration
#Mainform
;Menu
#MainMenu
;Menu Edit
#SelectAll
#Cut
#Copy
#Paste
#Editor
EndEnumeration
Define.l Event, WEvent, GEvent
Global WindowStyle.i=#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget
Procedure Open_MainForm()
OpenWindow(#Mainform, 0, 0, 500, 400, "New Form", WindowStyle)
EditorGadget(#Editor, 10, 30, 480, 360, #PB_Editor_WordWrap)
CreateMenu(#MainMenu, WindowID(#Mainform))
MenuTitle("File")
MenuTitle("Edit")
MenuItem(#SelectAll, "Select All" + Chr(9)+"Ctrl+A")
MenuItem(#Cut, "Cut" + Chr(9) + "Ctrl+X")
MenuItem(#Copy, "Copy" + Chr(9) + "Ctrl+C")
MenuItem(#Paste, "paste" + Chr(9) + "Ctrl+V")
EndProcedure
Open_MainForm()
Repeat
Event = WaitWindowEvent()
MEvent = EventMenu()
GEvent = EventGadget()
Select Event
Case #PB_Event_Menu
Select MEvent
Case #SelectAll
SendMessage_(GadgetID(#Editor), #EM_SETSEL,0,-1)
Case #Cut
SendMessage_(GadgetID(#Editor), #WM_CUT, 0, 0)
Case #Copy
SendMessage_(GadgetID(#Editor), #WM_COPY, 0, 0)
Case #paste
SendMessage_(GadgetID(#Editor), #WM_PASTE, 0, 0)
EndSelect
Case #PB_Event_Gadget
Select GEvent
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti
Sorry for my bad english and the Dunning–Kruger effect
-
- User
- Posts: 59
- Joined: Sun Jul 21, 2013 8:30 am
Re: Copying & Pasting from an EditorGadget
Falsam, thanks. But I think I just wasted your time. I just installed the newest beta 5.2, and it allows one to copy and paste from the editorgadget. Maybe that was there before in 5.11, but I think it wasn't.falsam wrote:Cut, Copy & PasteCode: Select all
Enumeration #Mainform ;Menu #MainMenu ;Menu Edit #SelectAll #Cut #Copy #Paste #Editor EndEnumeration Define.l Event, WEvent, GEvent Global WindowStyle.i=#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget Procedure Open_MainForm() OpenWindow(#Mainform, 0, 0, 500, 400, "New Form", WindowStyle) EditorGadget(#Editor, 10, 30, 480, 360, #PB_Editor_WordWrap) CreateMenu(#MainMenu, WindowID(#Mainform)) MenuTitle("File") MenuTitle("Edit") MenuItem(#SelectAll, "Select All" + Chr(9)+"Ctrl+A") MenuItem(#Cut, "Cut" + Chr(9) + "Ctrl+X") MenuItem(#Copy, "Copy" + Chr(9) + "Ctrl+C") MenuItem(#Paste, "paste" + Chr(9) + "Ctrl+V") EndProcedure Open_MainForm() Repeat Event = WaitWindowEvent() MEvent = EventMenu() GEvent = EventGadget() Select Event Case #PB_Event_Menu Select MEvent Case #SelectAll SendMessage_(GadgetID(#Editor), #EM_SETSEL,0,-1) Case #Cut SendMessage_(GadgetID(#Editor), #WM_CUT, 0, 0) Case #Copy SendMessage_(GadgetID(#Editor), #WM_COPY, 0, 0) Case #paste SendMessage_(GadgetID(#Editor), #WM_PASTE, 0, 0) EndSelect Case #PB_Event_Gadget Select GEvent EndSelect Case #PB_Event_CloseWindow End EndSelect ForEver
Anyway, everything's great now, thanks for the input.