[fxruby-users] FXTextField - posSelected?(pos)

Lyle Johnson lyle at knology.net
Mon May 15 21:45:23 EDT 2006


On May 15, 2006, at 3:21 PM, Gérard Ménochet wrote:

>     On a FXtextField, I want to detect the low and high pos of the 
> selected string
>  
>     example: the text is:  0123456789
>  
>     The selected string is :    234567
>  
>      first = last = -1
>       atext.text.length.times  do |pos|
>            first = pos  if atext.posSelected?(pos) and first < 0
>            last = pos  if atext.posSelected?(pos)
>       end
>       puts " first = #{first}    last = #{last}"
>
>  
>        Result:  last ==  8   !!!!!!   ===> problem , 8 is not selected

I don't know a lot about this function, but am looking at the FOX 
source code for it. Tell me, what do cursorPos and anchorPos return in 
this scenario?

	atext.length.times do |pos|
		first = ...
		last = ...
	end
	puts "first ..."
	puts "cursorPos = #{atext.cursorPos}"
	puts "anchorPos = #{atext.anchorPos}"

Thanks,

Lyle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1544 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/fxruby-users/attachments/20060515/3893bf73/attachment.bin 


More information about the fxruby-users mailing list