Page 1 of 1

Pop up menus with columns instead of scroll

Posted: 14 Mar 2019 15:27
by jaywalker32
Is it possible to make long pop-up menus show in two or more columns instead of having to scroll? A setting or a tweak? :?:

Re: Pop up menus with columns instead of scroll

Posted: 14 Mar 2019 15:48
by highend
XY inbuilt ones? No.

Re: Pop up menus with columns instead of scroll

Posted: 15 Mar 2019 05:25
by jaywalker32
What about custom menus from popupmenu()?

Re: Pop up menus with columns instead of scroll

Posted: 15 Mar 2019 07:22
by highend
You have control over their design so create columns if they would be too long on low screen sizes...

Re: Pop up menus with columns instead of scroll

Posted: 15 Mar 2019 11:31
by jaywalker32
I can limit the number of items displayed using the [count] option but cannot find an option to split overlong menus into multiple columns.

eg.

Code: Select all

popupmenu(quicksearch("*.xys",,"|"), 4:=100);
Can you give me pointer on how I would go about splitting this into two columns instead of the default column with the scroll bars at the top and bottom?

Re: Pop up menus with columns instead of scroll

Posted: 15 Mar 2019 12:31
by highend
popupmenu doesn't have submenus...

Code: Select all

    $splitOn = 50;

    $results = quicksearch("*.xys");
    $cntResults = gettoken($results, "count", <crlf>);

    $splits = $cntResults % $splitOn;
    if ($splits) { $splits = regexreplace(($cntResults / $splitOn), "(\d+)(\.|,)\d*", "$1") + 1; }
    else { $splits = $cntResults / $splitOn; }

    $menu = "";
    while ($i++ < $splits) {
        if ($i * $splitOn > $cntResults) { $max = $cntResults; }
        else { $max = $i * $splitOn; }

        if ($i == 1) {
            $menu .= "$i - " . $max . <crlf>;
            $items = gettoken($results, $splitOn, <crlf>, , 1);
        } else {
            $menu .= ($i * $splitOn) - $splitOn + 1 . " - " . $max . <crlf>;
            $getThis = gettoken($results, $max, <crlf>, , 1);
            $items = gettoken($getThis, ($i * $splitOn) - $splitOn + 1, <crlf>, , 2);
        }
        $menu .= regexreplace($items, "^(.)", "<space 4>$1") . <crlf>;
    }
    $selection = popupnested($menu);

Re: Pop up menus with columns instead of scroll

Posted: 15 Mar 2019 13:39
by jaywalker32
Thanks. I can see how it would work.