Hi everybody, I need a help. I have some contents in a scrolling field and I want to delete the selected from that list. I've tried a lot through delete, clear, put empty commands and also selectedtext, selection, selectedline and selectedchunk functions to do that but failed.
Before my posting, I've tried all of these codes. And after your replies, I've tried both of them again renaming my field "asd" to "Field". But failed again. I tried this -
on mouseUp
delete the selectedText of field "Field"
end mouseUp
And got this error -
button "Button": execution error at line 2 (Handler: can't find handler) near "the", char 4
Then I tried this one -
on mouseUp
put empty into the selectedText of field "Field"
end mouseUp
And got this error -
button "Button": execution error at line 2 (Chunk: no target found), char 14
I'm using rev ent. 4. As far as I know, the aboves should work; but I'm afraid why they don't?
on focusOut -- for locked text fields
set the cLastSelection of me to the selectedChunk
end focusOut
on exitfield -- for editable fields
set the cLastSelection of me to the selectedChunk
end exitfield
this way you make a custom property of the field that gets filled with the last selection. This custom property you can access from your button.
Something like
on mouseUp
put the cLastSelection of field 1 into mySelection
if word 4 of mySelection < word 2 of mySelection then exit mouseUp -- no text selected, just the insertion mark is in the field
put the number of lines of char 1 to (word 2 of mySelection) of field 1 into tNumOfLines -- find out how many lines up to the begin of the selection
delete line tNumOfLines of field 1
end mouseUp
If this is the problem then I can not really test it because I dont have access to a windows computer. You might want to experiment with this a bit.
Regards
Bernd
Yes, I'm using windows xp and its the text locked field. Thanks Bernd for your reply but it doesn't work for me. Oh ! its really making me disappointed.
Putting empty into the selectedText deletes the text but that line turns to an empty line and still exists. Is there any way to delete that empty line?
My apologies, I thought you were trying to delete part of a line that had been selected IE removing a portion of the text. If you just want to remove all hilited lines in a list field you can do this.
A slight variation may be required if you are deleting multiple lines, as when you delete the first line in the list, then every other line below it will be shuffled up one line, and the next delete will be offset by a line, and that can compound over the repeat loop too. If you sort the hilitedLines list first, so that you delete the highest line number then the next highest, etc, each line number in the list will still match the original selection:
on mouseUp
put the hilitedLines of field "Field" into tLines
sort tLines descending
repeat for each item tLine in tLines
delete line tLine of field "Field"
end repeat
end mouseUp
put the hilitedLines of field "FullList" into tLines
sort items of tLines descending
repeat for each item tLine in tLines
delete line tLine of field "FullList"
end repeat