DougO
July 22, 2020, 4:29am
1
Hi All,
I was wondering if anyone else has run into this issue. I currently have an HTML dialog which I would like to ensure the user doesn’t close.
On windows, I just set the ‘Set can close’ value to false, which works great. But on Mac it doesn’t seem to do anything.
Have any of you run into this, or found a solution? Am i doing anything obviously silly?
options = {
:dialog_title => 'Shy Ghost',
:style => UI::HtmlDialog::STYLE_WINDOW,
:scrollable => false,
:resizable => false,
:width => 240,
:height => 240
}
dialog = UI::HtmlDialog.new(options)
dialog.set_html($shyghostdialog).to_s
dialog.set_position(5000, 5000)
dialog.set_can_close { false }
dialog
Have you checked the official API Issue Tracker ?
Issues · SketchUp/api-issue-tracker · GitHub
I find …
opened 07:04PM - 06 Jun 20 UTC
closed 11:08AM - 10 Jun 21 UTC
bug
Ruby API
SketchUp
logged
ui
fixed-SU2021.1
Incredible that after 4 years, either nobody noticed, or nobody uses it...
**… _CONTEXT_**: **Mac OSX only, all Sketchup versions SU2017 to SU2020**. Works fine as specified on Windows, all SU versions.
**_PROBLEM_**: the ```set_can_close(&can_close_proc)``` method is completely ineffective on Mac. Precisely
1. Whatever the call back ```can_close_proc``` returns, the dialog window will close right away
2. If the answer is ```false``` (keep open), it is worse, as the method set in ```set_on_closed``` is not even called
3. If the answer is ```true``` (ok to close), then ```set_on_closed``` is called.
This can be reproduced with the piece of code below (normally, the window should close after 4 attempts):
``` ruby
def test_can_close
hsh = { :title => "Test can close", :preferences_key => "TestCanClose"}
wdlg = UI::HtmlDialog.new(hsh)
@iter = 0
wdlg.set_can_close { @iter += 1 ; puts "CAN CLOSE iter = #{@iter}" ; (@iter > 4) }
wdlg.set_on_closed { puts "FINALLY CLOSED" }
wdlg.show
end
```
**_REQUEST_**: Make it work
DougO
July 22, 2020, 6:51am
3
Obviously I didn’t… Thanks Dan. I’ll check it out a bit more in the future.
@thomthom & @Mark
Although there is no solution to the glitter fading from my shirt or the hair falling from my head, I feel that SU-46390 might solve one of my problems. HAHA.