Clicking a table cell causes OnItemAction to fire

General TRichView support forum. Please post your questions here
Post Reply
aoven
Posts: 45
Joined: Wed Nov 09, 2005 7:28 pm

Clicking a table cell causes OnItemAction to fire

Post by aoven »

I noticed that OnItemAction fires with ItemAction = rviaInserting when clicking inside a cell if caret was previously outside.

I figure this happens because of the trick with a nested inplace editor, which comes transparently to life when a cell is being edited. However, for all practical purposes this is a false event. It shouldn't fire if insertion is a result of an internal inplace editor creation.

Can it be fixed? If not, what can I do to detect when OnItemAction is being triggered by a valid change in the editor and when it's a false alarm?
aoven
Posts: 45
Joined: Wed Nov 09, 2005 7:28 pm

Post by aoven »

After digging through the source, I found a way to detect the situation. In OnItemAction I check Sender.Focused value. If it's False, then the event is a result of inplace editor being filled with cell contents. If it's True, then it's a genuine event.

The question remains if this check will still work with the next RV version. Is this likely to change, Sergey?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Calling this event in this case is by design - items are informed that their parent RVData is changed (cell -(editing)-> inplaceeditor and back).
I am not sure about the Focused property, may be it is False by accident.
How do you use this event? If you maintain a list of inserted items (of some type), you can check if they were already inserted.
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

Dear Sergey,

I found the same problem when a picture is nested in a table the rviaInserted is used while the picture isn't inserted by the user.

I use the following sourceparts:

Code: Select all

rve->RVFOptions = rve->RVFOptions >> rvfoSavePicturesBody >> rvfoSaveBack;

ONRVFPictureNeeded event for loading images from the harddisc and internet.

And the rviaInserted in the OnItemAction for saving some picture properties to a file.
Could you please advise me what to do?

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

?
OnItemAction with rviaInserted is called when the item is already inserted in the list of items of RVData, and its index in this list is known.
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

When I insert a picture the 'rviaInserted' is used. Like it should be. But when I select a picture which is nested in a table the 'rviaInserted' is also used. When a picture is outside a table and I select it, the 'rviaInserted' is not used.

Try it out adding a 'messagebox' in the 'rviaInserted'.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

"Inserted" is called every time when the item is moved to another document (i.e. another RVData). This includes moving to cell inplace editor and back to the cell (it happens on selection).
So it is by design.
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

I understand. Is there a way to recognize if a picture is nested in a table? My application uses 'rviaInserted' for recognizing new added pictures. A picture which already is inserted shouldn't be recognized.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The most reliable way is checking if this image is already in the list.
Post Reply