Here is an example that duplicates the problem.
Plugins/MyStartup.rb
require 'sketchup.rb'
require 'extensions.rb'
# Show the Ruby Console at startup so we can
# see any programming errors we may make.
SKETCHUP_CONSOLE.show
module Sketchup::MyTest
#Register the Tools with SU's extension manager
myTestExtension = SketchupExtension.new("My Test Tool", "MyTest/MyTestMenu.rb")
#Default on in pro and off in free
Sketchup.register_extension myTestExtension, true
end # module Sketchup::MyTest
Plugins/MyTest/MyTestMenu.rb
require 'sketchup.rb'
require 'MyTest/MyTestDialog.rb'
module Sketchup::MyTest
# Add a menu item to launch our plugin.
if( not $myTestMenuLoaded )
begin
$myTestDialog = MyTestDialog.new
mnuMenu = UI.menu('Extensions')
mnuMenu = mnuMenu.add_submenu('My Test')
mnuItem = mnuMenu.add_item('Run Test') { $myTestDialog.show }
rescue Exception
puts "#{$!}"
end
$myTestMenuLoaded = true
end
end # module Sketchup::MyTest
Plugins/MyTest/MyTestDialog.rb
module Sketchup::MyTest
class MyTestDialog
def initialize
begin
@oDialog = UI::HtmlDialog.new ({
:dialog_title => "My Test",
:style => UI::HtmlDialog::STYLE_DIALOG
})
@oDialog.add_action_callback("callBack") do |dialogContext,actionName|
puts actionName
case actionName
when 'getData'
js_command = "getData('getting data')"
when 'setData'
js_command = "setData('setting data')"
when 'okay'
@oDialog.close()
js_command = 'success()'
when 'cancel'
@oDialog.close()
js_command = 'success()'
else
js_command = 'success()'
end
puts js_command
@oDialog.execute_script(js_command)
end
htmlPath = Sketchup.find_support_file "MyTestDialog.html" ,"Plugins\\MyTest\\Dialogs"
@oDialog.set_file(htmlPath)
rescue Exception
puts "#{$!}"
end
end
def show
begin
@oDialog.show()
rescue Exception
puts "#{$!}"
end
end
end
end # module Sketchup::MyTest
Plugins/MyTest/Dialogs/MyTestDialog.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>My Test Dialog</title>
</head>
<body>
<input id="txtTest">
<br>
<br>
<input onclick="evntGetClick()" id="btnGet" value="Get" type="button">
<input onclick="evntSetClick()" id="btnSet" value="Set" type="button">
<input onclick="evntOkayClick()" id="btnOkay" value="Okay" type="button">
<input onclick="evntCancelClick()" id="btnCancel" value="Cancel" type="button">
<br>
<br>
<script type="text/javascript" src="MyTestDialog.js">
</script>
</body>
</html>
Plugins/MyTest/Dialogs/MyTestDialog.js
// Call sketchup application
function callBack(value) {
try {
sketchup.callBack(value);
} catch(err) {
alert("Error in [callBack]: " + err.message);
}
}
// Get data
function getData(value) {
try {
document.getElementById("txtTest").value = value;
} catch(err) {
alert("Error in [getData]: " + err.message);
}
}
// Set data
function setData(value) {
try {
document.getElementById("txtTest").value = value;
} catch(err) {
alert("Error in [getData]: " + err.message);
}
}
// Get data
function evntGetClick() {
try {
callBack("getData")
} catch(err) {
alert("Error in [evntGetClick]: " + err.message);
}
}
// Set data
function evntSetClick() {
try {
callBack("setData")
} catch(err) {
alert("Error in [evntSetClick]: " + err.message);
}
}
// Okay and exit
function evntOkayClick() {
try {
callBack("setData")
callBack("okay");
} catch(err) {
alert("Error in [evntOkayClick]: " + err.message);
}
}
// Cancel and exit
function evntCancelClick() {
try {
callBack("cancel");
} catch(err) {
alert("Error in [evntCancelClick]: " + err.message);
}
}
// Initialize form
try {
callBack("getData");
} catch(err) {
alert("Error in [initialization]: " + err.message);
}