Button to toggle Drag & Drop between Copy and Move?

Would it be possible to create a button that toggles the way events behave? I read this and it is very helpful, however I wish it was a quicker way to change it and change it back. Thanks

It should be possible using a global variable.

What do you want to do?

For now I want a button that when clicked changes the the default Drag and Drop to move. When clicked (toggled back) again changes the default back to copy. I think once I see this done for this, I can also create useful thing with many events. Thanks

Does the global variable fill in where a string like "Copy MOVE" does? Then change when you click a button? Thanks

I think it would work in two ways.

  1. A button could set a variable. A custom script could check that variable and change is functionality based on the value.
  2. A button could change a Dopus setting. by running a dopus command.

Looking at what you are linking, I think your button would need to change a dopus setting.

Here is a button I use to change a variable and then call a function. That script reads the variable and changes what it does.

<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" textcol="none">
	<label>RegulateCalcFolderSizes</label>
	<tip>Set CalcFolderSizesfor for tab</tip>
	<icon1>#RegulateCalcFolderSizesBasic:RegulateCalcFolderSizesOn</icon1>
	<function type="normal">
		<instruction>@toggle:if $src:autosize</instruction>
		<instruction>@icon:#RegulateCalcFolderSizesBasic:RegulateCalcFolderSizesOff,CALCFOLDERSIZES=off</instruction>
		<instruction />
		<instruction>@ifset:$src:autosize</instruction>
		<instruction>@set src:autosize</instruction>
		<instruction>RegulateCalcFolderSizes</instruction>
		<instruction>@ifset:else</instruction>
		<instruction>@set src:autosize=true</instruction>
		<instruction>RegulateCalcFolderSizes</instruction>
		<instruction>GO REFRESH</instruction>
		<instruction>@ifset:common</instruction>
	</function>
</button>

Here is a button that Toggles a dopus setting.

<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" separate="yes" textcol="none">
	<label>Navigation Lock</label>
	<tip>Lock together the navigation of both sides of a dual-display Lister</tip>
	<icon1>#navlock</icon1>
	<function type="normal">
		<instruction>Set NAVLOCK=Toggle</instruction>
	</function>
</button>

I don't think you would need to to change any settings, nor use scripts for this.

You can have a button which toggles a global variable (or a variable local to the lister, or folder tab, if preferred). Then the event could do things differently based on whether or not the variable is set (which can be done with @ modifiers, no scripting required, unless things get more complex).

I haven't had a chance to sit at my PC and work out exactly what would be needed to toggle the drag & drop between copy and move, but I don't think it will end up being anything complex.

wowbagger, thanks for showing me your button. Super helpful in understanding certain concepts even if there is a simpler way to do what I want like Leo says. Leo, thanks for any attempt to find a solution for what I want. This program and its community is always GREAT!! Thanks

This button will toggle a global variable named DragIsMove, and will visually appear enabled when in Move mode:

@toggle:if $glob:DragIsMove
@ifset:$glob:DragIsMove
@set $glob:DragIsMove
@ifset:else
@set $glob:DragIsMove=true

200dpi_wc10332_dopus
Move Mode.dcf (525 Bytes)


This drag-and-drop event will Move or Copy, depending on whether or not the DragIsMove variable is set:

@ifset:$glob:DragIsMove
Copy MOVE
@ifset:else
Copy

2 Likes

That is Fantastic! So useful! Thanks a lot!

Is it possible to have an icon also switch with this? I have created a *.dis within Opus and added it. I can recognize the icons by their simple name. I see with some of the toggle style buttons I can get the icon to toggle. However, I cannot get this code to toggle the icon. Also, I see that the toggle highlights the button area in one state, can this be eliminated when (and if) the icons can toggle? Thanks

You can use @icon for that, adding 2 lines to the old command:

@toggle:if $glob:DragIsMove
@icon:move,$glob:DragIsMove
@icon:copy,!$glob:DragIsMove
@ifset:$glob:DragIsMove
@set $glob:DragIsMove
@ifset:else
@set $glob:DragIsMove=true

If you paste that as the command, then hold Ctrl and click on either instance of @icon:, Opus will open an icon selector so you can change it to another icon if you don't want to use the built-in copy and move icons as in the example.

Oooh... that's why it is blue. This is great! Thanks

Could the icon be set via a script function? I mean icon for the button that is pressed? Here is my first try at it, but I think I need to understand more. Thanks

function OnClick(clickData)
{	
	var i
	var cnt
	var gVars = ["Acrobat","Illustrator","Word","Access"]
	var gVicon = ["Acrobat","Illustrator","Word","Access"]
	var cmm = DOpus.Create.Command
	
	for ( i = 0; i < gVars.length; i++ ){
		if (DOpus.Vars(gVars[i]).persist){
			cnt = i 
			DOpus.Vars(gVars[i]).persist = false
			//return
		} else {
			if (!cnt){
				DOpus.Vars(gVars[0]).persist = true
			}
		}
	}
	// This is where I want to set the button's icon?
	cmm.RunCommand ( "@icon:" + gVicon[cnt] )
	cmm.UpdateToggle()
	
	if ( DOpus.Vars(gVars[cnt]).name == DOpus.Vars(gVars[gVars.length - 1]).name ){
		DOpus.Vars(gVars[0]).persist = true
	} else {
		DOpus.Vars(gVars[cnt+1]).persist = true
	} 

	DOpus.Output(DOpus.Vars(gVars[cnt]).name)
}

What's the aim here exactly? When will the script make the different icons be used?

(If it isn't related to the thread subject anymore, better to create a new thread for it.)

It will make them used when the global variable is set. Then the setting in the events area of the file types can take advantage of it. Visually it will let us know what is set e.g. if we double click a file it will open with a certain program for a time, shown by the icon. Thanks

Continued here:

The second part does not seem to work for me on version 12.14

Always makes drag'n'drop be Move, no matter if DragIsMove is set or not.

It should still work.

Are you editing the right event, and sure it's being used for the files/types you're dragging?

Try setting the event to run Help ABOUT (as the whole command) and see if the About window appears when you trigger it. If the About window appears when you drag then, then you know you were editing the right event, but if it doesn't then it means it was the wrong one.

Test with normal directories as well, since things like FTP may override drag & drop events in some situations.

Aha! That was a brilliant debugging suggestion, it turns out that it does indeed work, the tooltip just doesn't update! (it says "Move to ...", whether DragIsMove is True or unset)
Thanks for the help!