Hide and show a button in a table cell on RichViewEdit
Hide and show a button in a table cell on RichViewEdit
Hello! Help me please. I write a program in which the main component is a table created in RichViewEdit. In this table, I need a button to appear when clicking on certain cells, clicking on which displays the menu, and when the cell loses focus, the button disappears. Looking for how to do it on the documentation for a week, did not understand how to achieve this. The button I added, but how to make it appeared when focus a cell and its disappearance or hide when focus is lost, is unclear.
Re: Hide and show a button in a table cell on RichViewEdit
Hi,
maybe you have to check for the current item to handle your visible/unvisible problem.
As a startting point you can have a look
here: http://www.trichview.com/help/idh_trich ... rentItemEx
or here: http://www.trichview.com/help/idh_trich ... titem.html
Greetings...
maybe you have to check for the current item to handle your visible/unvisible problem.
As a startting point you can have a look
here: http://www.trichview.com/help/idh_trich ... rentItemEx
or here: http://www.trichview.com/help/idh_trich ... titem.html
Greetings...
Re: Hide and show a button in a table cell on RichViewEdit
Thanks. This method i am used. How to make the button (rvsComponent) inserted into the table not move along with the text? How to set the cursor to enter text into a specific cell of the table in RichViewEdit?
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Hide and show a button in a table cell on RichViewEdit
I think that control insertion is not a good solution. As I understand, you do not need to modify document, you need just display a button.
I can suggest using a "smart popup". It is a button that can be shown next to the current item. It displays an icon and, optionally a triangle (useful if this button shows a menu) or ellipsis (useful if this button shows a dialog).
You can use this code in OnCaretMove to hide/show "smart popup":
The only minus: this button is positioned next to the current item (bottom right corner by default; you can specify another corner); you cannot define its coordinates.
Additional info: http://www.trichview.com/help/idh_trich ... rties.html
I can suggest using a "smart popup". It is a button that can be shown next to the current item. It displays an icon and, optionally a triangle (useful if this button shows a menu) or ellipsis (useful if this button shows a dialog).
You can use this code in OnCaretMove to hide/show "smart popup":
Code: Select all
procedure TForm3.RichViewEdit1CaretMove(Sender: TObject);
begin
// showing when the caret is in table cell
RichViewEdit1.SmartPopupVisible := RichViewEdit1.InplaceEditor <> nil;
// this cell can be get as:
// RichViewEdit1.TopLevelEditor.RVData.GetSourceRVData as TRVTableCellData
end;
Additional info: http://www.trichview.com/help/idh_trich ... rties.html
Re: Hide and show a button in a table cell on RichViewEdit
Thank you very much. This mehod is good. How to disable the ability to change the external dimensions of the border with the mouse?
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Hide and show a button in a table cell on RichViewEdit
Do you mean disabling table resizing?
Exclude rvtoRowSizing and rvtoColSizing from table.Options
Exclude rvtoRowSizing and rvtoColSizing from table.Options
Re: Hide and show a button in a table cell on RichViewEdit
Thank you very much.
Re: Hide and show a button in a table cell on RichViewEdit
Is there any way to determine whether the cursor is on the left or right side of the table?
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Hide and show a button in a table cell on RichViewEdit
I am sorry for the delay.
There is a demo project that contains table and does not allow to move the caret outside of it:
http://www.trichview.com/forums/viewtop ... f=3&t=6382
Below is a code fragment from this demo showing how to implement this feature.
rveCaretMove processes rve.OnCaretMove event. If the caret is outside of a table cell, it sends a message that invokes WMBackToTable procedure.
(we cannot move the caret directly inside OnCaretMove event, so we cannot directly call WMBackToTable, we need to use PostMessage)
Additionally, if we are inside a table cell, we storing this cell and the caret position in it.
In WMBackToTable, we starting editing cell and moving the caret to the last position in it. So, when the user tries to move the caret outside the table, it is immediately moves back.
This demo assumes that this table and cells inside it cannot be deleted. Otherwise, we need to intercept these operations and assign nil to Cell.
There is a demo project that contains table and does not allow to move the caret outside of it:
http://www.trichview.com/forums/viewtop ... f=3&t=6382
Below is a code fragment from this demo showing how to implement this feature.
Code: Select all
const WM_BACKTOTABLE = WM_USER+1;
TfrmNoteList = class(TForm)
...
Moving: Boolean;
procedure WMBackToTable(var Msg: TMessage); message WM_BACKTOTABLE;
...
end;
procedure TfrmNoteList.rveCaretMove(Sender: TObject);
begin
if not Visible or Moving then
exit;
if (rve.InplaceEditor=nil) and not (rvstCreatingInplace in rve.RVData.State) then begin
PostMessage(Handle, WM_BACKTOTABLE, 0, 0);
exit;
end;
if rve.InplaceEditor=nil then
exit;
Cell := rve.TopLevelEditor.RVData.GetSourceRVData as TRVTableCellData;
ItemNo := rve.TopLevelEditor.CurItemNo;
Offs := rve.TopLevelEditor.OffsetInCurItem;
end;
procedure TfrmNoteList.WMBackToTable(var Msg: TMessage);
var RVData: TCustomRVFormattedData;
begin
if not Visible or (rve.InplaceEditor<>nil) or (Cell=nil) then
exit;
Moving := True;
try
RVData := Cell.Edit as TCustomRVFormattedData;
RVData.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);
finally
Moving := False;
end;
end;
(we cannot move the caret directly inside OnCaretMove event, so we cannot directly call WMBackToTable, we need to use PostMessage)
Additionally, if we are inside a table cell, we storing this cell and the caret position in it.
In WMBackToTable, we starting editing cell and moving the caret to the last position in it. So, when the user tries to move the caret outside the table, it is immediately moves back.
This demo assumes that this table and cells inside it cannot be deleted. Otherwise, we need to intercept these operations and assign nil to Cell.
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Hide and show a button in a table cell on RichViewEdit
Sorry if the information above does not answer to your question. I believe your initial question was about not allowing placing the caret outside of the table.
As for this question:
As for this question:
Is there any way to determine whether the cursor is on the left or right side of the table?
Code: Select all
if RichViewEdit1.InplaceEditor <> nil then
exit; // the caret is inside a table
if not (RichViewEdit1.GetCurrentItem is TRVTableItemInfo) then
exit; // the caret is not near the table
if RichViewEdit1.OffsetInCurItem = 0 then
<before table>
else
<after table>
-
- Posts: 1
- Joined: Sat Jul 28, 2018 10:30 am
Re: Hide and show a button in a table cell on RichViewEdit
Thank you very much. This mehod is good. How to disable the ability to change the external dimensions of the border with the mouse?
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Hide and show a button in a table cell on RichViewEdit
Do you mean resizing images or resizing table columns and mouse?