<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[My Visual Database — Grid Custom Popup Menu, Right Click and Selection Problem]]></title>
		<link>https://myvisualdatabase.com/forum/viewtopic.php?id=9162</link>
		<atom:link href="https://myvisualdatabase.com/forum/extern.php?action=feed&amp;tid=9162&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Grid Custom Popup Menu, Right Click and Selection Problem.]]></description>
		<lastBuildDate>Sun, 02 Feb 2025 17:29:00 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Grid Custom Popup Menu, Right Click and Selection Problem]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=52043#p52043</link>
			<description><![CDATA[<p>I hoped that everything would work out and so it did. ) This was checked.<br />The menu item can be: made invisible, turned off, deleted, inserted, added, etc. Without nil. I hope you paid attention to the menu on the right with classes. There are properties and methods for classes described there.<br />Everything is correct with GetCursorPos and .Popup.<br />Between Down and Up, the program calls the menu, paints the line, etc., simultaneously interrupting the process of executing other functions. This is not a problem, this is the program&#039;s work. The problem is sometimes how to get around it.</p>]]></description>
			<author><![CDATA[null@example.com (sparrow)]]></author>
			<pubDate>Sun, 02 Feb 2025 17:29:00 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=52043#p52043</guid>
		</item>
		<item>
			<title><![CDATA[Re: Grid Custom Popup Menu, Right Click and Selection Problem]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=52042#p52042</link>
			<description><![CDATA[<p>Thank you sparrow for your prompt reply and help!</p><p>Per your recommendation, I ended up hiding all of the current menu items (oddly that := nil didn&#039;t work for me, but I used the .Visible) and created a new menu which I triggered to show on right click using GetCursorPos and .Popup.</p><p>Just to note that the problem I was facing when I initially created this post still exists - using the existing context menu wasn&#039;t an option. The existing menu triggers <strong>before</strong> the OnMouseUp event of the grid which means anything I place to change the existing menu - Enable, Visible etc. - will only run <strong>after</strong> the menu shows (essentially the update will always be in on click delay).</p><p>But! as long as there is another way to achieve it, it is great!</p><p>Thank you again!</p>]]></description>
			<author><![CDATA[null@example.com (SandBird)]]></author>
			<pubDate>Sun, 02 Feb 2025 14:30:20 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=52042#p52042</guid>
		</item>
		<item>
			<title><![CDATA[Re: Grid Custom Popup Menu, Right Click and Selection Problem]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=52037#p52037</link>
			<description><![CDATA[<p>Hi</p><br /><p>The function of deleting a row with a mouse can be enabled in the table properties. <br />But if you want to create additional conditional deletion items, you will have to manage the process manually. <br />You do not need to use your procedure in all table events.<br />You can try the following:<br />1. In the OnShow event of the main form, disable all items of the current PopUp menu of the table (Visible false). <br />&nbsp; &nbsp;Disabling all items prevents the program from automatically showing the menu by right-clicking.<br />2. Create your own menu items or modify existing ones with the visibility of menu items turned off. Create events.<br />3. In the OnMouseUp event, analyze the right-click, the number of selected rows. Enable the visibility of the menu item/items. <br />&nbsp; &nbsp;Manually call the PopUp display by coordinates. Turn off the visibility of the menu item.</p><br /><p>For the operation of deleting a row or all rows, you can do with one menu item. In point 3, before the visibility of the menu item, <br />change the name of the menu item. Analysis and execution of code for different situations is done in the event that is assigned <br />to this menu item.</p>]]></description>
			<author><![CDATA[null@example.com (sparrow)]]></author>
			<pubDate>Sat, 01 Feb 2025 10:27:04 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=52037#p52037</guid>
		</item>
		<item>
			<title><![CDATA[Grid Custom Popup Menu, Right Click and Selection Problem]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=52035#p52035</link>
			<description><![CDATA[<p>Hello,</p><p>I have been testing out this software and so far it is brilliant!</p><p>However, I have encountered a problem that I am unsure how to solve and would like to know if there is any solution, perhaps I am doing something wrong? (I am new to Pascal).</p><p><strong>In summary:</strong> I think when you right-click on a grid row, the SelectedCount gets updated <span class="bbu">after</span> the actions of OnMouseUp/OnMouseDown&nbsp; which means one can&#039;t utilize the count for changing items in the menu.</p><p><strong>A little bit in depth:</strong> I have a grid with some rows and a custom popup menu. The menu is defined as a separate procedure and gets to run every time there is either OnChange and OnMouseUp/OnMouseDown event.</p><p>Something like (simplified):<br /></p><div class="codebox"><pre><code>PopupMenuItem := TMenuItem.Create (PopupMenu);
PopupMenuItem .Caption := &#039;Always Visible&#039;;
PopupMenuItem .OnClick := @proc1;
PopupMenu.Items.Add(PopupMenuItem);

if (form.grid.SelectedCount &gt; 0) and (form.grid.RowCount &gt; 0) then
begin
  PopupMenuItem := TMenuItem.Create (PopupMenu);
  PopupMenuItem .Caption := &#039;Remove Selected&#039;;
  PopupMenuItem .OnClick := @proc2;
  PopupMenu.Items.Add(PopupMenuItem);
end;

if form.grid.RowCount &gt; 0 then
begin
  PopupMenuItem := TMenuItem.Create (PopupMenu);
  PopupMenuItem .Caption := &#039;Remove All&#039;;
  PopupMenuItem .OnClick := @proc3;
  PopupMenu.Items.Add(PopupMenuItem );</code></pre></div><p><strong>The problem:</strong> upon first load of the GUI when nothing is selected in the grid, if you <span class="bbu">right-click</span> on one of the rows, the menu that shows will not show &quot;Remove Selected&quot;, only upon a second mouse click it will show it. As I explained, with my tests I think the SelectedCount is updated after the actions of actions of OnMouseUp/OnMouseDown.</p><p>I also tried the OnClick/OnCellClick events but from what I tested they only get triggered upon a left-click and not right-click.</p><p>Is there anyway to solve this? perhaps a better approach to all of this &quot;custom popup menu&quot; since one must also consider keyboard input etc.?</p><p>Any input would be much appreciate - thank you in advance!</p><p>SandBird</p>]]></description>
			<author><![CDATA[null@example.com (SandBird)]]></author>
			<pubDate>Sat, 01 Feb 2025 03:15:33 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=52035#p52035</guid>
		</item>
	</channel>
</rss>
