Here is a rework of that code that I found most useful for me. As I was
leaning how to do this, I experimented with different syntaxes for data
retreval.
'€€€€€€€€€€€€€€€€€€€€€€€
'=================================================================
local fn displayTextSelected$(efID as short, linenumber as short)
'=================================================================
// Function displays the line of text selected in a scrolling edit field
dim as handle @teH
dim as short numCharacters, startSelection, endSelection
dim mySelection$
//Make sure we don't select a line greater than what's in the edit fld
teH = TEHANDLE(EFid)
long if linenumber + 1<= teH..teNLines%
startSelection= {[TEHANDLE(EFid)] + _teLines + (linenumber * 2)}
linenumber ++
endSelection = {[TEHANDLE(EFid)] + _teLines + (linenumber * 2)}
numCharacters = endSelection - startSelection
// Different ways to extract the selected line of text:
//
// Using text handles
//
// Move data to our STR...leave roomin front to insert Length byte.
blockmove [fn TEGETTEXT(TEHANDLE(EFid))] + startSelection, @mySelection$+1
,numCharacters
//insert Length byte at 1-st position
poke @mySelection$, numCharacters
'--------
//mySelection$ = Edit$(efID, lineNumber)
'--------
//mySelection$ = Edit$(efID, startSelection, endSelection);
'--------
//Hilite the selected line.
handleevents
Edit Field #efID'make ef active
// the following are equivalent:
Setselect startSelection, endSelection
'tesetselect( startSelection, endSelection, teH)
xelse
mySelection$= "Outside data range"
end if
// Display results in edit field
'edit$(_cSelectionEdit) = mySelection$
end fn = mySelection$
'€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
J Smith
> Georg Wood wrote:
>
> I am trying to convert to Carbon from FB4. I am using a editfield to
> hold a list. I DO NOT WANT to use a listfield. How can I hilite the
> line in the editfield that is clicked on. I am using the font height to
> determine which line is clicked, and getting the number of that line.
> What I want to do is hilite/invert the text so it is obvious which line
> was selected.
>
> ----------------------------------------
>
> Perhaps this is what you want:
>
> ----------------------------------------
> Joe Smith wrote:
>
>> Have a scrollable text edit box displayed with multiple lines of data.
>> I click on a specific line. I want that line only to hilite.=A0 How.
>
>
> dim txt$
> dim X, nLines, yourLine, startLoc, endLoc
>
> WINDOW 1, "Click On Line Test", (0,0)-(200,300)
>
> txt$ =3D "This is a text sample."
> txt$ =3D txt$ + "Try clicking on a line of text to see what happens. "
> txt$ =3D txt$ + "Hopefully this will select the entire line of text "
> txt$ =3D txt$ + "that was clicked on. This is a messy example, but I "
> txt$ =3D txt$ + "didn't have time to make it look nice."
> txt$ =3D txt$ + CHR$(13) + "Have fun."
> edit field 1, txt$, (1,1)-(180,280)
>
> WHILE 1
> handleevents
>
> nLines =3D PEEK WORD(PEEK LONG(WINDOW(18))+94)
> LONG IF nLines > 1
> FOR X =3D 1 TO nLines
> yourLine =3D X
> LONG IF WINDOW(_selStart) < PEEK WORD(PEEK LONG(WINDOW(18)) + 94 + ((X) * 2)=
> )
> yourLine =3D X - 1
> X =3D nLines
> END IF
> NEXT X
> startLoc =3D PEEK WORD(PEEK LONG(WINDOW(18)) + 94 + ((yourLine) * 2))
> endLoc =3D PEEK WORD(PEEK LONG(WINDOW(18)) + 94 + ((yourLine+1) * 2))
> SETSELECT startLoc, endLoc
> XELSE
> SETSELECT 0, 32767
> END IF
> WEND
>
> Al Staffieri Jr.
> ----------------------------------------
>
> There has been a related thread "Highlighting text in ThemeTextBox"
> on this list starting on March 31st.
>
> HTH