How can I best adapt the language in an "@Confirm really move these files?|yes|abort" evoked dialog to the language setting of the whole Dopus app?
(usage case: How to force confirmation on every "move" file operation?)
You can do with scripting for specific buttons and things, but there's no global/built-in way of getting custom and localized confirm dialog texts/buttons.
You might get away with just "@confirm" (providing no custom texts at all). In this case DO uses localized default texts.
First of all, thx for ur answer.
So, this is part of a drag & drop event.
Trying to keep things as simple as possible (rebuilding as little functionality as possible with a script):
- I thought of using @if but it seems that I can not query the Dopus.language setting with @if, correct?
- I also thought of mixing commands and scripting. E.g. with the Command object. But then it seems that this does not support the @confirm modifier, correct?
- I cannot inject a "normal" "Standard Function" with "real" script code (e.g. VBScript), correct? e.g:
if Dopus.language = "english"
@confirm ....
else
@confirm ....
copy movewhensame
This is not possible, also not with some other syntax, right?
Not totally sure wether "@confirm" won't do when putting command objects together, I'd actually expect it to work. Maybe try with .SetModifier('confirm','Really?'); But you have another option, the "Confirm" scriptaddin I made some time ago, it's a replacement for the @confirm modifier and should work quite well in an if/elseif/elseif construct.
Confirm script addin: haage-partner.de/forum/view ... =45&t=4926
Download the demo-menu button in the thread linked above and see how it works in scripts, another little usage example is here:
You should be able to put something together like:
[code]if (Dopus.language == "english")
objCommand.AddLine('Confirm MSG="Really?"');
elseif (Dopus.language == "german")
objCommand.AddLine('Confirm MSG="Wirklich?"');
else
objCommand.AddLine('Confirm MSG="?"');
objCommand.AddLine("Copy MOVEWHENSAME");
objCommand.Run();
[/code]
Maybe it's worth telling some more details behind the localization need, maybe there's a better solution.
You can use string resources for this. (That's what they exist for.)
Thx to both.
I did put a link with a/the usage case in the first post.
I thought they work only in a 100% script environment but not in a commands environment??
Correct, string resources are part of scripting.
There's also a Dialog object for displaying dialog boxes which is fairly simple to use (if the dialog box is simple; it can also do complex things, but they wouldn't be needed here).
If you want conditional logic, as the pseudo-code above is using, then you probably want to use scripting. Trying to do it without scripting usually only makes things more complicated, not less.
Thx, leo, it took me years (a couple) to give opus a serious try but now I am here and I really like the customizability, thx.
Ok, I would prefer not to use some script add-in in this case to make the drag & drop reactor as less dependent on other ressources as possible.
Therefore, I would like to give the confirm modifier a chance inside the command object.
I thought it is not supported, because the help file says about SetModifier:
[quote]Turns on a modifier for this command. The supported modifiers are a subset of the full list of command modifiers:
admin, async, codepage, externalonly, leavedoswindowopen, nodeselect, noexpandenv, nofilenamequoting, nolocalizefiles, norunbatch, resolvelinks, runmode[/quote]
But I am willing to give it a try.
Still & anyway I am not sure about how to code the script correctly in the event editor and about the command object itself in this context.
Here is what I have so far:
Do I need to add an "@script:vbscript" line or something similar, since this editor does not have the drop down box to select the scripting language? and how do I best create the command object in this case (I saw that there is more than one way to create it) and do I have to set the source and destination or anything, respectively how do I do that in the drag & drop event reactor? This event is not listed under Scripting Reference / Scripting Events.
Many thx in advance.
Ok, I changed my mind on trying to use the confirm modifier in scripting again.
What I have so far (in the file types drag & drop event editor) is this:[code]@script vbscript
if Dopus.language = "English" then
str_prompt = "Really move these file(s)?"
str_title = "Confirm Drag & Drop"
str_buttons = "&OK|&abort"
elseif Dopus.language = "Deutsch" then
str_prompt = "Diese Datei(en) wirklich verschieben?"
str_title = "Drag & Drop bestätigen"
str_buttons = "&OK|&abbrechen"
else
MsgBox(Dopus.language & " not supported")
end if
if Dopus.language = "English" or Dopus.language = "Deutsch" then
Set obj_Command = Dopus.Create.Command
Set dlg = obj_Command.Dlg
dlg.message = str_prompt
dlg.title = str_title
dlg.buttons = str_buttons
if dlg.show = 1 then
obj_Command.AddLine("Copy MOVEWHENSAME")
objCommand.Run()
end if
end if[/code]
The Dialog pops up fine but also on OKing it the command does nothing. What is wrong? Thx.
Ok, the "last" line must of course be
obj_Command.Run()
Then the command does something but the wrong thing.
It moves the selected files/folders to the other lister pane but not to the drop target.
and if I have a file selected in the "blue" lister pane and try to drag and drop a folder within the tree then the command goes completely wacko.
Regarding the help file: This is not very useful. Badly written.
It seems to me that I would have to add the source files and the target folder to the command object manually.
But how do I do that in this drag and drop event context?
Try this in a script/vbscript type button or use the full button download below.
[code]Option Explicit
Function OnClick(ByRef clickData)
dim prompt, title, buttons
if Dopus.language = "English" then
prompt = "Really move these file(s)?"
title = "Confirm drag'n drop"
buttons = "&Ok|&Abort"
elseif Dopus.language = "Deutsch" then
prompt = "Diese Datei(en) wirklich verschieben?"
title = "Drag'n drop bestätigen"
buttons = "&Ok|&Abbrechen"
else
MsgBox(Dopus.language & "is not supported")
exit function
end if
dim command : Set command = Dopus.Create.Command
dim dlg : Set dlg = command.Dlg
dlg.message = prompt
dlg.title = title
dlg.buttons = buttons
if dlg.show <> 1 then exit function
DOpus.Output "Running the command.."
'command.AddLine("Copy MOVEWHENSAME")
'command.Run()
End Function
[/code]
Download:
LocalizedConfirm.dcf (1.9 KB)
Please replace the line..
dim command : Set command = Dopus.Create.Command
with
dim command : Set command = clickdata.func.command
..to use the command object DO always prepares for you in these kind of button scenarios. It already holds the source tab and selected files for you, all is setup ready for use. No need to handle target location specifically in a dragndrop operation from my point of view, it'll work automagically! o)
Thx but I don't want this as a button. I want it as a reactor to a drag & drop event. I cannot see how this might help me out.
Ok, I did not see ur last sentence. Let me read...
I don't get it. Should I use the onClick reactor in the drag & drop event editor?
I don't get it. Should I use the onClick reactor in the drag & drop event editor?
Yep! o)
Ok, weired name of the reactor then, but I tried and it almost works:
[code]Option Explicit
Function OnClick(ByRef clickData)
dim prompt, title, buttons
if StrComp(Dopus.language, "english", vbTextCompare) = 0 then
'case insensitive string compare; result is 0 if equal (how stupid!)
prompt = "Really move these file(s)?"
title = "Confirm drag'n drop"
buttons = "&Ok|&Abort"
elseif StrComp(Dopus.language, "deutsch", vbTextCompare) = 0 then
'case insensitive string compare; result is 0 if equal (how stupid!)
prompt = "Diese Datei(en) wirklich verschieben?"
title = "Drag'n drop bestätigen"
buttons = "&Ok|&Abbrechen"
else
MsgBox(Dopus.language & " is not supported")
exit function
end if
dim command : Set command = clickdata.func.command
dim dlg : Set dlg = command.Dlg
dlg.message = prompt
dlg.title = title
dlg.buttons = buttons
if dlg.show <> 1 then exit function
'DOpus.Output "Running the command.."
command.AddLine("Copy MOVEWHENSAME")
command.Run()
End Function
[/code]
The behaviour regarding the actual moving or not moving of files/folders in this case works with this code now. But there is one small thing which I am still unhappy with: When I drag files/folders then it says in the tooltip "Copy to ..." when it should say "Move to ...". It correctly says "Move to ..." when I use the simple version without scripting and just one language.