Load script (custom menu) at selection?
Load script (custom menu) at selection?
Hi, I wan't to load a custom menu via keyboard shortcut at the selection, like POM, currently it loads at the mouse pointer.
Is there a way I can specify the position?
Is there a way I can specify the position?
Re: Load script (custom menu) at selection?
popupmenu() can be invoked with x | y coordinates but not at specific gui elements (list selections or anything like that).
One of my scripts helped you out? Please donate via Paypal
Re: Load script (custom menu) at selection?
I'm using load "rename.txt"
the txt file contains:
I wanted to make a seperate menu just for renaming files, because my POM is already too crowded. It's working, but everytime I use it, I have to search for the dialog box
And then I had the idea to make a seperate menu for file operations
Is it possible to load it in the center of XYplorers window?
the txt file contains:
Code: Select all
"Rename add date+sig" rename , "<date yymm> * - PN";
"Rename after current folder" rename , "<curfolder>";
etc
And then I had the idea to make a seperate menu for file operations
Is it possible to load it in the center of XYplorers window?
Re: Load script (custom menu) at selection?
There's the undocumented row and cell scripting commands which allow you to find a row index by item and then find coordinates for a particular column within that row.
You'll want to read a some of the posts starting here: http://www.xyplorer.com/xyfc/viewtopic. ... 19#p102919
That should allow you to show popupmenu near the selection, but I don't think you'll be able to easily determine the center of the list pane or window.
You'll want to read a some of the posts starting here: http://www.xyplorer.com/xyfc/viewtopic. ... 19#p102919
That should allow you to show popupmenu near the selection, but I don't think you'll be able to easily determine the center of the list pane or window.
Re: Load script (custom menu) at selection?
Managed to get it work, but it's offset, both in x and y direction.
Maybe it has something to do with the new Layout?
With offset correction
Maybe it has something to do with the new Layout?
With offset correction
$row = row(<curitem>);
$column = "name";
sel $row;
$x = cell($row, $column, "x");
$y = cell($row, $column, "b");
popupmenu("TEST", $x, $y+155);
Re: Load script (custom menu) at selection?
Is it supposed to load offset or am I doing something wrong?
Unfortunately my scripting skills are based on trial and error!
Unfortunately my scripting skills are based on trial and error!
Re: Load script (custom menu) at selection?
Eh... forget about my earlier post. It appears cell only returns positions relative to the top,left of the active list pane while popupmenu uses coordinates across the entire screen.
Maybe Don will improve this by adding a flag to cell to get the screen position instead.
Sorry for leading you astray!
Maybe Don will improve this by adding a flag to cell to get the screen position instead.
Sorry for leading you astray!
-
- Site Admin
- Posts: 60357
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Load script (custom menu) at selection?
screen position: yep, I can do that.
FAQ | XY News RSS | XY Twitter
-
- Site Admin
- Posts: 60357
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Load script (custom menu) at selection?
No time to doc this, but pass 1 as flags to convert it to screen position:
Code: Select all
syntax: cell(row, column, coord, [flags])
FAQ | XY News RSS | XY Twitter
Re: Load script (custom menu) at selection?
WOW, thanks, the flag is working as intended.admin wrote:No time to doc this, but pass 1 as flags to convert it to screen position:Code: Select all
syntax: cell(row, column, coord, [flags])
But I'm stuck again
As everybody can see from the scipt, it's only supposed to work with a single selection.
It would be a lot more useful if it would work with a multiselection. I browsed the scripting commands reference, but couldn't come up with anything good.
Code: Select all
$row = row(<curitem>);
$column = "name";
sel $row;
$x = cell($row, $column, "x", 1);
$y = cell($row, $column, "b", 1);
popupmenu("ALMOST", $x, $y);
Re: Load script (custom menu) at selection?
You don't need to call sel $row; in your script at all so removing that line should get you one step closer.
Re: Load script (custom menu) at selection?
I guess I could live with the 1. scenario, but now my computer makes a BING everytime I run the script
Re: Load script (custom menu) at selection?
The problem is <curitem> is the selected AND focused item but the dragging selection rectangle selects items without changing the focus.
In one case: hdkanafilee.jpg is focused but not in the selection so <curitem> is nothing and thus row() returns 1.
In the other job.gif is focused and in the selection so it is <curitem> and row(<curitem>) then returns 9.
The question then becomes where should the menu appear when multiple items are selected?
You could do something like this to show the menu after the first item in the selection:
Not sure why it's making noise for you as it is silent here.
In one case: hdkanafilee.jpg is focused but not in the selection so <curitem> is nothing and thus row() returns 1.
In the other job.gif is focused and in the selection so it is <curitem> and row(<curitem>) then returns 9.
The question then becomes where should the menu appear when multiple items are selected?
You could do something like this to show the menu after the first item in the selection:
Code: Select all
// Get list of selected items.
$items = Get('SelectedItemsPathNames');
// Default to the focused item if nothing is selected.
if ($items == '') {
$items = "<focitem>";
}
// Get first item from list.
// Replace 1 with -1 to use the last item from the list.
$item = GetToken($items, 1, "<crlf>");
$row = row($item);
$column = "name";
$x = cell($row, $column, "x", 1);
$y = cell($row, $column, "b", 1);
popupmenu("ALMOST", $x, $y);
Re: Load script (custom menu) at selection?
Thanks, now it's working flawlessly, I appreciate your input!
The BING sound was because I didn't had On KeyUp checked
The BING sound was because I didn't had On KeyUp checked