I’m porting a plugin from Windows to OS X and I have a very basic problem with UI::Commands. The validation proc callbacks aren’t called regularly. They are only called when I click on one of the default SketchUp toolbar buttons, not when I click on any of my own buttons.
Here’s a minimal example that exhibits the problem on SketchUp 2015 and 2016 on OS X El Capitan 10.11.3:
require 'sketchup.rb'
show_ruby_panel()
$toolbar_test_bool = false
cmdtext = "Toolbar Test"
cmd = UI::Command.new(cmdtext) {
$toolbar_test_bool = !$toolbar_test_bool
puts("bool == #{$toolbar_test_bool}")
}
cmd.set_validation_proc {
puts("validation proc")
if $toolbar_test_bool
puts("validation proc true")
MF_CHECKED
else
puts("validation proc false")
MF_UNCHECKED
end
}
toolbar = UI::Toolbar.new("Toolbar Test")
toolbar.add_item(cmd)
toolbar.show()