Scripting - popupmenu (bug(s))

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Scripting - popupmenu (bug(s))

Post by highend »

It seems, coordinates aren't working correctly (except from x=-1, x=-2 -> cursor).

This one is working fine and shows the menu at the cursor postion:

Code: Select all

popupmenu(<get selecteditemspathnames |>, x=-1, y=-1);
This one should display the menu at x=300, y=500 but it's in the top left
corner of the screen.

Code: Select all

popupmenu(<get selecteditemspathnames |>, x=300, y=500);
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 67332
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Scripting - popupmenu (bug(s))

Post by admin »

Wrong syntax; you confused my way to show the default values with the parameters themselves. This is the way to do it:

Code: Select all

popupmenu(<get selecteditemspathnames |>, 300, 500);

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Scripting - popupmenu (bug(s))

Post by Stefan »

Code: Select all

v10.50.0007 - 2011-11-02 19:40
    + Scripting got a new function.
      Name:   PopupMenu
      Action: Pops a menu and returns the selected item.
      Syntax: popupmenu(itemlist, [x=-1], [y=-1], [start=1], [count=-1], [flags=0], [sep_itemlist="|"], [sep_item=";"], [on_cancel=""])
        itemlist: List of items separated by sep_itemlist.
                Each item is made of a Caption and optionally a Data part, separated by sep_item: "Caption;Data"
        x:            X position; -1 to use current mouse X.
        y:            Y position; -1 to use current mouse Y.
        start:        Index of first item to show; 1 = first item.
        count:        Count of items to show; -1 = show all.
        flags:         1: Return index (instead of caption/data).
        sep_itemlist: Separates items; can have more than one char.
        sep_item:     Separates caption from data; can have more than one char.
        on_cancel:    String returned when menu is cancelled (ESC).
        return:       Data of selected item; caption if no data defined; index if flags AND 1.
      Examples:
        text popupmenu("a|-|b|c");  //- is a menu separator
        text popupmenu("a;data returned on a|-|b;data b|c;data c");
        text popupmenu(<get selecteditemspathnames |>);

Test

Code: Select all

  $a = "Execute with option x Xy XXyy";
  $b = "Execute with option K VbDFccs";
  $c = "Execute with option G BjfdUpa";
  
  //popupmenu(itemlist, x, y, start, count, flags, sep_itemlist, sep_item, [on_cancel=""])
  $r = popupmenu("Choose what to execute:| |$a|$b|$c|-|Cancel",-1,-1,,,1,,,"nix");

  msg "You have chosen item no: $r";

  if ($r==3){msg "OK, executing sub A.";}
  if ($r==4){msg "You want sub B? OK.";}
  if ($r==5){msg "...exec sub C.";}
  if ("$r"=="nix"){msg "nothing chosen. ESC pressed or wrong clicked.";}




Problem:
on_cancel: pressing ESC-key while the dialog is visible result in nothing: // "You have chosen item no: "
$r = popupmenu("Choose what to execute:| |$a|$b|$c|-|Cancel",-1,-1,,,1,,,"nix");

And so this are not executed too:
if ("$r"=="nix"){msg "nothing chosen. ESC pressed.";}
if ($r=="nix"){msg "nothing chosen. ESC pressed.";}

Or:
$r = popupmenu("Choose what to execute:| |$a|$b|$c|-|Cancel",-1,-1,,,1,,,0);
if ($r==0){msg "nothing chosen. ESC pressed.";}

Only this works:
$r = popupmenu("Choose what to execute:| |$a|$b|$c|-|Cancel",-1,-1,,,1,,,"");
$r = popupmenu("Choose what to execute:| |$a|$b|$c|-|Cancel",-1,-1,,,1,,);
if ($r==""){msg "nothing choosen. ESC pressed.";}



Idea:
- missing center option for X and Y: x="", y="" ==> center dialog.
Currently x="", y="" is the same as x=-1, y=-1

admin
Site Admin
Posts: 67332
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Scripting - popupmenu (bug(s))

Post by admin »

I cannot see a problem with on_cancel. :?

Centering the menu: Use <get screen width> and <get screen height> plus a little math. :wink:

Post Reply