Page 1 of 1
RichView.GetFocusedItem(RVData, ItemNo) - RVData is nil
Posted: Wed Dec 11, 2013 3:31 pm
by rjlth
Good day to all!
I am having problem with retrieving focused text in RichView. In documentation it is written that whit GetFocusedItem I can get the ItemNo of focused item. But RVData is nil and ItemNo is -1. Why can it be? Text style has "Jump" set to true, using tabs i switched between items, but can't get focused item.
Posted: Wed Dec 11, 2013 5:41 pm
by Sergey Tkachenko
This means that no item is focused at this time.
Items can be focused only in TRichView, not in TRichViewEdit.
Only hyperlinks and inserted controls can be focused. A focused link has a dotted frame.
Posted: Wed Dec 11, 2013 5:47 pm
by rjlth
But there is a focused item, it has dotted frame. And I am using TRichView.
If I add a new text item with style, that have "Jump" set to true, is this item a hyperlink?
Posted: Thu Dec 12, 2013 8:15 am
by rjlth
I have found some interesting thing. If I focus on this item and then press Enter, OnJump event is called. And in this event GetFocusedItem works properly. But if I click on item with right button (item gets dooted frame) to call my popupmenu, click on some menu item and try to call GetFocusedItem in menuitemclick procedure, RVData is nil.
Posted: Thu Dec 12, 2013 8:59 am
by rjlth
I have found out what the problem was.
Before calling GetFocusedItem I called SelectionExists. And SelectionExists resets focus. I have replaced
with
Code: Select all
RichView.RVData.SelectionExists(false, false)
and now everything works properly.