Re: Text Widget Confession [message #26741 is a reply to message #26626] |
Mon, 24 September 2001 09:46   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Pavel A. Romashkin (pavel.romashkin@noaa.gov) writes:
> David Fanning wrote:
>>
>> It turns out a list widget, although simplifying my
>> life, made other things more complicated.
>
> You could use widget_text, then, by modifying the code above to include
> the following (sorry for not providing this to start with :-):
>
> junk = where(strsplit(rs, string(1b), /extract) $
> ne theText, comp=good_rows, ncomp=count)
> if count ne 0 then theText = theText[good_rows]
> Widget_Control, textID, Set_Value=theText
>
> Its not copyrighted, you know :-)
No, I realize it's not copyrighted. But I feel
obligated to send you a check for $100 anyway
to compensate you for your time and effort. :-)
Cheers,
David
P.S. In case you are interested, here is the final
code responding to the Delete button:
************************************************************ ************
PRO Recorder::DeleteIt, event
; The method event handler deletes text lines in the current selection.
; Get the current text selection.
Widget_Control, self.textID, Get_Value=selectText, /Use_Text_Select
; Get the text itself.
theText = *self.text
; Hocus-pocus provided by Pavel Romashkin to circumvent
; RSI-supplied nonsense. V-E_R-Y clever! :-)
jt = StrJoin(theText, String(1b))
js = StrJoin(selectText, String(1b))
rs = jt
StrPut, rs, String( Byte(js) < 2b), StrPos(jt, js)
selection = Where(StrSplit(rs, String(1b), /Extract) NE thetext)
; Error checking. Look for no selection values.
IF N_Elements(selection) EQ 1 THEN BEGIN
IF selection[0] EQ -1 THEN RETURN
ENDIF
; Error checking. Look for no overlap between the two vectors.
overlap = self->SetDifference(Indgen(N_Elements(*self.text)), selection)
IF N_Elements(overlap) EQ 1 THEN BEGIN
IF overlap[0] EQ -1 THEN BEGIN
*self.text = ""
ENDIF ELSE BEGIN
*self.text = (*self.text)[overlap]
ENDELSE
ENDIF ELSE *self.text = (*self.text)[overlap]
Widget_Control, self.textID, Set_Value=*self.text
END
************************************************************ ************
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|