PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD18] Stop right click from changing the current selected row in table
[WD18] Stop right click from changing the current selected row in table
Iniciado por guest, 13,nov. 2014 18:18 - 2 respuestas
Publicado el 13,noviembre 2014 - 18:18
Hi

Does anybody happen to know how to keep the current record current when the user right clicks the right mouse button to bring up the popup menu from changing to the row that the mouse happens to be over.

ie:

I have a table of 10 records. The 3rd record (row) is the highlighted row. The users mouse happens to be over the 7th record (row) when the user clicks the right mouse button. The popup comes up but (this is what I want to stop) now the 7th record (row) is now the current record (row). I do not want the right mouse click to change the current record (row).

Can this be done and if so could someone please tell me how it is done or point me in the right direction in any case. Thanks for any help I might receive.
Publicado el 13,noviembre 2014 - 20:11
Hi John

This can be done with a bit of extra coding, not pretty but it does work.
Dependent on you requirements you may need to adapt but this should give you a starter.

First, if you have not already done so addEXTERN "KeyConst.WL" to your project initialisation.

In the global declaration of the window containing the table control declare a variable. wsSaveRowPos is string
In the row selection code... IF KeyPressed(VK_RBUTTON) = False THEN //If left click (Selection) - save the current row wsSaveRowPos = TableSavePositionAndSelection(MyTable) //Your normal selection code follows here ELSE //Hide selection bar on clicked row TableSelectMinus(MyTable) //Popup will now activate END
In the Popup menu (THIS HAS TO BE ON EVERY SELECTION CODE).
//Restore the table position to the last selection TableRestorePositionAndSelection(Table_PivotTotals,wsSaveRowPos) //Clear the TableSave info wsSaveRowPos = "" //Run your menu selection code //Execute your table selection code ExecuteProcess(MyTable,trtSelection)
The other thing to take into consideration is that Popup menus close as soon as they loose focus regardless of whether a selection was made.
You will therefore need to add an 'On Focus Gain' to the table code and add IF wsSaveRowPos <> "" THEN wsSaveRowPos = TableSavePositionAndSelection(MyTable) ExecuteProcess(Table_PivotTotals,trtSelection) END
And finally depending on your window you may need the same in the Window On Focus code section.

HTH
Publicado el 14,noviembre 2014 - 01:11
Hi Derek:cheers:

Thanks for the help and your time an effort. I was hoping there would be a simpler way to do it. I have 69 tables synced together. So this improvement isn't looking pretty for me. <img src="/NG2013_WEB/ui/smiley/2.gif" align=absmiddle border=0 alt=":(">

But I am really grateful for your time and effort.