ShellAnything icon indicating copy to clipboard operation
ShellAnything copied to clipboard

Use visibility, reboot disabled

Open Vzz1c opened this issue 1 year ago • 8 comments

<?xml version="1.0" encoding="utf-8"?>
<root>
  <shell>
	<menu name="Select the left file for comparison">
	      <visibility isempty="${select.left.path}" />
	      <actions>
                    <property name="select.left.path"     value="${selection.path}" />
                    <property name="select.left.path.filename" value="${selection.filename}" />
             </actions>
	</menu>
    <menu separator="true" />
    <menu name="Compare">
      <visibility properties="select.left.path" />
      <menu name="Compare with '${select.left.path}' (text)">
        <icon path="C:\Windows\System32\imageres.dll" index="14" />
        <visibility properties="select.left.path" />
        <actions>
			<exec path="${env.ComSpec}" arguments="/K FC /L &quot;${select.left.path}&quot; &quot;${selection.path}&quot;"  basedir="${selection.parent.path}" />
			<property name="compare.first.selection.path"     value="" />
			<property name="compare.first.selection.filename" value="" />
			<property name="select.left.path"     value="" />
			<property name="select.left.path.filename" value="" />
        </actions>
      </menu>
	     <menu name="Select file '${selection.filename}'">
        <actions>
          <property name="select.left.path"     value="${selection.path}" />
          <property name="select.left.path.filename" value="${selection.filename}" />
        </actions>
      </menu>
    </menu>
    <menu separator="true" />
  </shell>
</root>

After rebooting, I have to comment out the following, then manipulate the context menu, and then turn the comment off to get it to work.

<visibility isempty="${select.left.path}" />

Vzz1c avatar Jul 30 '24 01:07 Vzz1c

It has nothing to do with rebooting, it doesn't seem to be supported.

		<menu name="test444">
			<visibility isempty="${select333}" />
			<actions>
				<property name="select333"     value="${selection.path}" />
				<property name="select333" value="${selection.filename}" />
			</actions>
		</menu>

test1

Vzz1c avatar Jul 30 '24 02:07 Vzz1c

Use bug to achieve effects like this

Vzz1c avatar Jul 30 '24 02:07 Vzz1c

Hi. I do not understand what you are trying to achieve. To me, the animated gif that you posted is working file. Can you specify your expectations?

Here is how I understand the animation:

  1. When there is nothing previously selected, you get the menu Select the left file for comparison. This menu is only visible if property select.left.path is empty. See isempty in UserManual for details.
  2. Once you have selected a "left file",
    1. The menu Select the left file for comparison is not displayed anymore.
    2. Instead, you see "Compare" with 2 menus: Compare with '${select.left.path}' (text) and Select file '${selection.filename}' (select a left file again)
  3. If you select Compare with xyz.bin, you run the action <property name="select.left.path" value="" /> which will reset the whole thing:
    1. Property select.left.path is empty again.
    2. Next right-click will show the menu Select the left file for comparison.

You can have a look at the logs. The code which updates the visibility and validity of a menu is located in Menu.cpp#L205. I think the details of why a menu is not displayed should be detailed. Look in the INFO level logs.

Regarding your menu example above (the one named test444). The menu should be displayed only once. All futures right-click will not display menu test444. Here is the details:

  1. On first right-click, property select333 is considered empty since it does not exists yet. The menu test444 should then be displayed. See isempty attribute validation for details.
  2. When you click on file foo.bar, and select menu test444, its actions are executed.
    1. The first action defines property select333 to value ${selection.path}.
    2. The second action defines same property again. This effectively overrides the previous action. This action re-define property select333 to value ${selection.filename}. Property select333 is now set to foo.bar.
  3. When you click on any file again, menu test444 will never be displayed again. This is because property select333 is not empty. It is set to foo.bar.

Like I said, I am uncertain of what you are trying to do. Have you looked at the inversed attribute? With this attribute you can inverse the logic of an operator. For example, you could "Validates a menu if the given text is not empty.". This would allow you to create two menu with inversed logic (one being the inverse of the other), effectively creating an "if, else" logic.

Waiting for your feedback.

end2endzone avatar Aug 01 '24 22:08 end2endzone

I am sorry, the INFO logs do not contain the details of about why a menu is visible or not. I have a planned feature to implement verbose logging in #109. This feature will specify the detail why a menu was set invisible. Right now, I think the logs shows the updated "visible" state of each menu. For example, at step 3, the menu will always show as "not visible" in the logs.

end2endzone avatar Aug 01 '24 22:08 end2endzone

<visibility isempty="${select.left.path}" />==><visibility properties="select.left.path" inverse="properties"/> It's working fine now, but I don't understand, properties inverse, isn't it the same as isempty? But I don't understand, properties inverse, isn't it equivalent to isempty?

Vzz1c avatar Aug 03 '24 07:08 Vzz1c

To clear your confusion, yes, isempty="${select.left.path}" is the same as properties="select.left.path" inverse="properties".

You can quickly test it with the following :

      <menu name="TEST1">
        <visibility isempty="${select.left.path}" />
      </menu>
      <menu name="TEST2">
        <visibility properties="select.left.path" inverse="properties" />
      </menu>

(menus TEST1 and TEST2 will always be BOTH visibles or BOTH invisibles).


The properties attribute validates that specified property names are empty. Multiple properties can be specified. For example: select.left.path;name;application. The isempty attribute accept a string expression (text). The content between the double-quotes must be empty for the menu to be visible. When using a single property name, one is equals to the inverse of the other.

Here is an example for each of them:

    <default>
      <property name="select.left.path" value="foobar" />
      <property name="select.right.path" value="" />
    </default>
  
    <menu separator="true" />
    <menu name="issue151">
    
      <menu name="1. NOT visible because text 'S{select.left.path}' is not empty">
        <!-- Programmatically, it is something like this:   NOT(text "${select.left.path}" is empty) -->
        <visibility isempty="${select.left.path}" />
      </menu>
      
      <menu name="2. Visible because NOT(text 'S{select.left.path}' is empty)">
        <!-- Programmatically, it is something like this:   !"${select.left.path}".IsEmpty() -->
        <visibility isempty="${select.left.path}" inverse="isempty" />
      </menu>

      <menu name="3. Visible because property 'select.left.path' is not empty">
        <!-- Programmatically, it is something like this:   GetValue("select.left.path").IsEmpty() -->
        <visibility properties="select.left.path" />
      </menu>
      
      <menu name="4. NOT visible because NOT(property 'select.left.path' is not empty)">
        <!-- Programmatically, it is something like this:   !GetValue("select.left.path").IsEmpty() -->
        <visibility properties="select.left.path" inverse="properties" />
      </menu>



      <menu name="5. Visible because text 'S{select.right.path}' is empty">
        <visibility isempty="${select.right.path}" />
      </menu>
      
      <menu name="6. NOT Visible because text 'S{select.right.path}' is not empty">
        <visibility isempty="${select.right.path}" inverse="isempty" />
      </menu>

      <menu name="7. NOT visible because property 'select.right.path' is not empty">
        <visibility properties="select.right.path" />
      </menu>
      
      <menu name="8. Visible because property 'select.right.path' is NOT empty">
        <visibility properties="select.right.path" inverse="properties" />
      </menu>

    </menu>
    <menu separator="true" />

end2endzone avatar Aug 06 '24 22:08 end2endzone

Did I help clear up the confusion? Is your problem resolved?

end2endzone avatar Aug 15 '24 21:08 end2endzone

Did I help clear up the confusion? Is your problem resolved?

end2endzone avatar Sep 08 '24 01:09 end2endzone