RichView.GetFocusedItem(RVData, ItemNo) - RVData is nil

General TRichView support forum. Please post your questions here
Post Reply
rjlth
Posts: 4
Joined: Wed Dec 11, 2013 3:25 pm

RichView.GetFocusedItem(RVData, ItemNo) - RVData is nil

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
rjlth
Posts: 4
Joined: Wed Dec 11, 2013 3:25 pm

Post 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?
rjlth
Posts: 4
Joined: Wed Dec 11, 2013 3:25 pm

Post 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.
rjlth
Posts: 4
Joined: Wed Dec 11, 2013 3:25 pm

Post by rjlth »

I have found out what the problem was.
Before calling GetFocusedItem I called SelectionExists. And SelectionExists resets focus. I have replaced

Code: Select all

RichView.SelectionExists
with

Code: Select all

RichView.RVData.SelectionExists(false, false)
and now everything works properly.
Post Reply