
get selected text of editor gadget
-
- User
- Posts: 15
- Joined: Sun Sep 12, 2004 6:41 am
get selected text of editor gadget
title says it all 

Edit:
Sorry, didn't realise this was a feature request, hence the code below.
(I used "view posts since last visit" and didn't check the forum name.)
Anyhow, just in case it was a request for code, will leave the code below.
Sorry, didn't realise this was a feature request, hence the code below.
(I used "view posts since last visit" and didn't check the forum name.)
Anyhow, just in case it was a request for code, will leave the code below.
Code: Select all
winID=OpenWindow(0,0,0,300,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar,"SOMETHING")
If winID
gadList=CreateGadgetList(WindowID(0))
If gadList
edGadID=EditorGadget(1,5,5,290,290)
If edGadID
lastSz=0 ; klurge - to stop debug window scrolling until change
lastCh=0 ; klurge - to stop debug window scrolling until change
Repeat
Event = WaitWindowEvent()
; ------- DEFINE YOUR OWN TRIGGER
; This triggers when any selection done.
SendMessage_(edGadID,#EM_EXGETSEL,0,Range.CHARRANGE)
siz=Range\cpMax-Range\cpMin
If siz<>0 And (lastSz<>siz Or lastCh<>Range\cpMin)
lastSz=siz
lastCh=Range\cpMin
w.s=Space(siz*2)
SendMessage_(edGadID,#EM_GETSELTEXT,0,w)
Debug Str(siz)+": "+w
EndIf
Until Event = #PB_EventCloseWindow
EndIf
EndIf
EndIf
@}--`--,-- A rose by any other name ..
-
- User
- Posts: 15
- Joined: Sun Sep 12, 2004 6:41 am
Hi Yian_The_Craft.
First, wish I could say I worked it out but I didn't. I learned it and other things from the smarter folk using this forum.
Second, it is a winapi call, not a PureBasic command. PureBasic, or the registered version, allows for calls to windows functions. All you need to to is stick a "_" after the windows function name, eg, SendMessage(.. becomes SendMessage_(..
You can find these functions in the windows SDK (downloadable from MS) or the older help file (sure to be a link to that somewhere in the forums).
If you read through the forums you will find bucketloads of useful stuff from the gurus here. You can also download a massive amount of code from http://www.purearea.net (the code archive).
The forum for asking questions is the beginners forum, help comes faster on that forum (this one is requests to Fred to add functionality to PureBasic) After I first answered your post and then saw where it was posted I nearly deleted my response because I thought you might be requesting that this be added to functionality, eg something like:
First, wish I could say I worked it out but I didn't. I learned it and other things from the smarter folk using this forum.
Second, it is a winapi call, not a PureBasic command. PureBasic, or the registered version, allows for calls to windows functions. All you need to to is stick a "_" after the windows function name, eg, SendMessage(.. becomes SendMessage_(..
You can find these functions in the windows SDK (downloadable from MS) or the older help file (sure to be a link to that somewhere in the forums).
If you read through the forums you will find bucketloads of useful stuff from the gurus here. You can also download a massive amount of code from http://www.purearea.net (the code archive).
The forum for asking questions is the beginners forum, help comes faster on that forum (this one is requests to Fred to add functionality to PureBasic) After I first answered your post and then saw where it was posted I nearly deleted my response because I thought you might be requesting that this be added to functionality, eg something like:
- w.s=GetEditorSelectedText(#Gadget)

Last edited by Dare2 on Sun Sep 12, 2004 12:11 pm, edited 1 time in total.
@}--`--,-- A rose by any other name ..
-
- User
- Posts: 15
- Joined: Sun Sep 12, 2004 6:41 am