Copy link to clipboard
Copied
Hi all,
Is this possible to trigger the UI button in script through keyboard enter?
Hello Raghav,
Try following one, Tested on mac not PC
function myUI() {
var w = new Window('dialog')
var b = w.add('button', undefined, 'click', { name: "ok" })
b.onClick = b_click
b.active = true
w.show()
function b_click() {
alert('here!')
}
}
myUI()
When we give name property as "ok", it responds to the enter key automatically. If you give another value of name instead of "ok", it will not work.
Copy link to clipboard
Copied
Yes, set the button to active:
theButton.active = true;
Copy link to clipboard
Copied
hi, you can use something like this:
function myUI(){
var w = new Window('dialog')
var b = w.add('button',undefined,'click')
b.onClick = b_click
w.addEventListener('keydown', function(e){
if(e.keyName == 'Enter'){
b_click()
b.active = false
}
})
w.show()
function b_click(){
alert('here!')
}
}
myUI()
Copy link to clipboard
Copied
This functionality is applicable for both Mac and PC. Actually I'm Checking Mac it wont works.
Copy link to clipboard
Copied
Hello Raghav,
Try following one, Tested on mac not PC
function myUI() {
var w = new Window('dialog')
var b = w.add('button', undefined, 'click', { name: "ok" })
b.onClick = b_click
b.active = true
w.show()
function b_click() {
alert('here!')
}
}
myUI()
When we give name property as "ok", it responds to the enter key automatically. If you give another value of name instead of "ok", it will not work.
Copy link to clipboard
Copied
Thanks Charu! Its Work fine.
Copy link to clipboard
Copied
You're welcome 🙂
Copy link to clipboard
Copied
Hi Charu,
Is there any UI options to hide/show the multiple folder selection path. For example, in the UI I have select 3 folder options to choose the folder, now I have added another 5 folder selection option in the UI. But the UI show three 3 folder in UI. Need to add (+)(-)button to show/hide the another folder selectin options in the UI
Copy link to clipboard
Copied
Hi Raghav,
Yes this is possible. Read following document by Peter Kahrel
On Page 72, there is an example of adding control dynamically. I hope this is what you are looking for.
Copy link to clipboard
Copied
Hi Charu,
This is the UI design I have looking for. If the user click the + button row 3 will insert like wise it will incremented. if it possible i will try but it wont work.
Copy link to clipboard
Copied
Hi Raghav,
Yes it is possible. Did you try at your end, then please share your code where it is not working. I can share the code for the above dialog, but that won't help you a lot till the time you will not try yourself. Attached is the screenshot that is created by me. So that means it is possible. As you said, you will try but it won't work, then please share your code what you have tried and let's debug together what will not work.
 
Copy link to clipboard
Copied
Thanks Charu, for reply I done that one forgot to mentioned. Now its working fine. I ll share the code.
var dialog = new Window("dialog", undefined, undefined, {su1PanelCoordinates: true, independent: true});
dialog.text = "Dialog";
var maingroup = dialog.add("panel {orientation: 'column'}");
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 21;
var group10 = dialog.add("group", undefined, {name: "group1"});
group10.orientation = "row";
group10.alignChildren = ["left","center"];
group10.spacing = 10;
group10.margins = 0;
group10.alignment = ["right","top"];
var iconbutton1_imgString = "";
var iconbutton1 = group10.add("iconbutton", undefined, File.decode(iconbutton1_imgString), {name: "iconbutton1", style: "toolbutton"});
iconbutton1.text = "Add Links Folders";
iconbutton1.alignment = ["left","center"];
iconbutton1.onClick = add_btn;
// PANEL1
// ======
var panel1 = dialog.add("panel", undefined, undefined, {name: "panel1"});
panel1.text = "Panel";
panel1.orientation = "column";
panel1.alignChildren = ["left","top"];
panel1.spacing = 10;
panel1.margins = 10;
var group6 = dialog.add("group", undefined, {name: "group6"});
group6.orientation = "row";
group6.alignChildren = ["left","center"];
group6.spacing = 10;
group6.margins = 0;
var button6 = group6.add("button", undefined, undefined, {name: "button6"});
button6.text = "OK";
var button7 = group6.add("button", undefined, undefined, {name: "button7"});
button7.text = "CANCEL";
add_row(maingroup);
dialog.show();
function add_row(maingroup){
if(panel1.children.length<10){
var group1 = panel1.add("group", undefined, {name: "group1"});
group1.orientation = "row";
group1.alignChildren = ["left","center"];
group1.spacing = 10;
group1.margins = 0;
var statictext1 = group1.add("statictext", undefined, undefined, {name: "statictext1"});
statictext1.text = "StaticText";
var edittext1 = group1.add('edittext {properties: {name: "edittext1"}}');
edittext1.preferredSize.width = 500;
var button1 = group1.add("button", undefined, undefined, {name: "button1"});
button1.text = "Browse";
button1.onClick = function(){
var InputFolder = Folder.selectDialog("Choose the Input Folder");
if(InputFolder != null){
edittext1.text = InputFolder.fullName;
}
}
var iconbutton1_imgString = "";
var iconbutton1 = group1.add("iconbutton", undefined, File.decode(iconbutton1_imgString), {name: "iconbutton1", style: "toolbutton"});
iconbutton1.onClick = minus_btn;
group1.index = panel1.children.length - 1;
dialog.layout.layout (true);
}else{
alert("Maximum 10 Folders Allowed");
}
}
function add_btn () {
add_row (maingroup);
}
function minus_btn () {
panel1.remove (this.parent);
dialog.layout.layout (true);
}
Copy link to clipboard
Copied
Great!