inputselect parent from tabbed list

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
rur54
Posts: 46
Joined: 12 Feb 2015 19:52

inputselect parent from tabbed list

Post by rur54 »

hi and my appology for a quick dirty question as I am writing this on work break from my phone.

any way through scripting to select parent of an item from tabbed list in inputselect.

example:
I import lightroom text file as a taglist into checkboxed inputselect so I get some grouping since there is no hiearchal tag support yet. looks like this:

Code: Select all

x family
x    lastname
x     firstname
x friends
x   lastname
x      firstname
x is supposed to represent a checkbox :)
so now I when I select firstname, any way to have it automatically select all parents as well? like lastname and family?

if there is any confusion in my explanation I will write again once I get some time at home.
cheers

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: inputselect parent from tabbed list

Post by highend »

Immediately when you are inside the inputselect() box?
Not possible.

Afterwards, when only a subitem has been selected?
Could be scripted.
One of my scripts helped you out? Please donate via Paypal

rur54
Posts: 46
Joined: 12 Feb 2015 19:52

Re: inputselect parent from tabbed list

Post by rur54 »

Thanks for reply highend.
Yes, from within inputselect(). I know it was not possible but was hoping there was a scripting trick or something.

SammaySarkar made a great little wrapper for popupnested() here:
viewtopic.php?p=147965#p147965
I used that to open taglist as a popup menu and it was great as I could get entire path "family lastname firstname" but as I thought, got old pretty quick to be clicking multiple times on the menu and looking into submenus to add multiple tags to file.

Right now what I have is fine (tabbed list in inputselectbox), I can manually select all items but would be helpful to be automated with one click.

Could you give me an idea how I would go about scripting this other way afterwards?
Cheers

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: inputselect parent from tabbed list

Post by highend »

Looking further at your example I'd say, no you can't do it (in a reliable way)...

Why not?

Code: Select all

family
    lastname
        firstname
friends
    lastname
+       firstname
The plus is there to indicate that you selected the second firstname entry

The variable that captures the return value of inputselect will now contain:

Code: Select all

        firstname
It's not possible for a script to know which firstname you've checkboxed, the first
or the second one. In other words, if the list contains items with the same name
it wouldn't work.

The only thing that would help is an enhancement for inputselect()
From the help file:
128 = Return selected index (first item = "1"). If nothing is selected, "0" (zero) is returned.
Note: Cannot be meaningfully combined with style 2 or 16
If Don would add either a new flag or another style value like this:
256 = If 128 is used, return all selected indexes in a |-separated list
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: inputselect parent from tabbed list

Post by PeterH »

Hm - a bit strange.
As I understand, if *only* a "firstname" is selected, it's "lastname" and "group" should be returned, too? (It doesn't seem to me that rur54 wants to explicitely select all these, too.)

But: if the script knows about the hierarchy (e.g. having built a table), and inputselect returns the entry number, the script could rebuild what is wanted.

To your request: yes, it might make sense to allow multiple selections (for other means), and return a list of either the selected entries, or their numbers.

*Currently* it seems like a docu- :bug: to me that "style"-value 2 says "prefix items with...", as I understand that currently only one selection seems to be allowed?

By the way: the real problem here seems to be, that inputselect isn't hierarchical in any way.
W7(x64) SP1 German
( +WXP SP3 )

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: inputselect parent from tabbed list

Post by highend »

As I understand, if *only* a "firstname" is selected, it's "lastname" and "group" should be returned, too?
Judging from his example, more than one subentries can be selected
But: if the script knows about the hierarchy (e.g. having built a table), and inputselect returns the entry number, the script could rebuild what is wanted
Not if my previous assumption is true (and there is more than one firstname selected in the table)

Feature request: viewtopic.php?f=5&t=17297
One of my scripts helped you out? Please donate via Paypal

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: inputselect parent from tabbed list

Post by SkyFrontier »

PeterH wrote: By the way: the real problem here seems to be, that inputselect isn't hierarchical in any way.
Which in my view is the key point, too: I often wanted easier ways to select all\invert selection\select none when it comes to inputselect(). Never occurred to me that hierarchization would be an answer and, looking backwards, that would helped a lot in many cases, using a certain folder depth in ways of an actual live filtering - for selections.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: inputselect parent from tabbed list

Post by PeterH »

OK: learned a bit, and don't understand another bit.

Learned: for style=2 (= check boxes) multiple entries are allowed. Then a list is returned.

Don't understand: if style=2+128, why is it forbidden, as a list of numbers could be returned?
OK - highends request is to build a new style=256 for this. But why not do it in general?
(If you only allow one selection: don't use check boxes, but click.
If you use check boxes: always allow multiple selections, even for 2+128.)

Further: I don't know exactly what's to achieve.
As I understand, this is an ordered list of persons - why not make each entry like
Family Smith Joe
(These entries might be constructed by script.) Then everything for one (or each) person is returned as wanted.
W7(x64) SP1 German
( +WXP SP3 )

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: inputselect parent from tabbed list

Post by highend »

Don't understand: if style=2+128, why is it forbidden, as a list of numbers could be returned?
Can break existing scripts.
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: inputselect parent from tabbed list

Post by PeterH »

highend wrote:
Don't understand: if style=2+128, why is it forbidden, as a list of numbers could be returned?
Can break existing scripts.
I don't think so.
In the moment it's forbidden for a script to define 2+128. So no script can use it now.
So who would be affected if it now would be allowed and return a list?
W7(x64) SP1 German
( +WXP SP3 )

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: inputselect parent from tabbed list

Post by highend »

In the moment it's forbidden
No, it's not forbidden. It just returns the first index atm. And you don't get a script
error or anything else when you use 128+2 for style currently.

Any script that uses 128 would now face a return value that could not only contain a single value, but a |-separated
list of values (when you use + 2). Potential script breaking...
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: inputselect parent from tabbed list

Post by PeterH »

What's wrong with my test?

A small test script works as expected when style=2 or =128.
But for style=2+128 it always returns 0 - nor matter if none, 1 or multiple elements are selected.

So here 2+128 can not be used?

Code: Select all

   $l = <<<#>>>
a
 b
  c
  d
e
 f
  g
h
#>>>;
   $s = InputSelect("Select!", $l, "<crlf>", 2+128);

   echo $s;
W7(x64) SP1 German
( +WXP SP3 )

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: inputselect parent from tabbed list

Post by highend »

Apparently nothing if this combination has a different return value than when using 128 alone.
So in this case yeah, he could change the current behavior :)
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: inputselect parent from tabbed list

Post by PeterH »

...and Help says for style=128:
Note: Cannot be meaningfully combined with style 2 or 16.

So a script doing it now would violate it :naughty:

I'd say: it could be enhanced to allow 2+128.
W7(x64) SP1 German
( +WXP SP3 )

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: inputselect parent from tabbed list

Post by TheQwerty »

Where were you in 2014? viewtopic.php?p=113769#p113769

You are both mistaken in believing that 128 returns the index of the checked item. Read the documentation with my emphasis added:
128 = Return selected index (first item = "1"). If nothing is selected, "0" (zero) is returned.
It cannot be meaningfully combined with checkboxes (2) because checked is not the same as selected.

Trying checking all items in the list and then Ctrl+Clicking the focused item to unselect it and you'll get back an index of 0, or use Ctrl+Up/Down to move focus to an unchecked item.


Should there be a difference between checked and selected here?
Don seemed to think so in 2014, but I disagreed since I doubt anyone comprehends 128 to literally mean the selected item regardless of checks.

Unfortunately, It's been this way since introduction so changing could break scripts.
However, the combination of the two flags has been discouraged nearly as long, and I would be surprised if anyone relied on the actual existing behavior of 2+128 ignoring checkboxes, so I feel it is probably okay to make 128 returns the selected/checked index(es).

EDIT: While we're at it, 2+16 should probably return the original list in the new order with the checked items prefixed by the preselect character(s).
Ideally, 2+16+128 would do the same but return the original indexes instead, but that's getting ugly so maybe just leaving the "Cannot be meaningfully combined" note there for 16+128 is okay.

Post Reply