I create a webDialog ,and select a tool in the funtion attached by “add_action_callback”, and I find the mouse wheel is useless while tool is actived.
XXX.add_action_callback(“create_xml”)
{|dialog, arg|
Sketchup.active_model.select_tool(MyTool.new)
}
However, the mouse wheel is available if I use “Sketchup.active_model.select_tool(MyTool.new)” directly,whicht is not called in the function of webDialog add_action_callback.
how to make the mouse wheel available while tool is actived in the function of WebDialog add_action_callback.
It happens because the web dialog still has the input focus instead of the main modeling window.
This is a known issue.
Search this category for “focus ” and you’ll find discussions … and perhaps hacky workarounds.
A search reveals …
These issues have been opened in the issue tracker …
opened 09:10PM - 17 Jun 20 UTC
closed 11:09AM - 10 Jun 21 UTC
bug
Ruby API
SketchUp
logged
ui
fixed-SU2021.1
This is a problem for **Windows only**. It works fine on Mac
**When you click… on the title bar of a dialog, there is NO focus event generated**, whether the listener is capturing ```focus()``` or ```activate()``` events).
Therefore, although the user has the 'impression' that the dialog has got the focus and is active, keyboard events are not received.
It really looks like, in Windows, the dialog frame window has been added, but sadly, entirely ignored by the CEF browser part (hence the fact that the inner and outer size are the same).
Yet another discrepancy between Windows and Mac...
**REQUEST**: Would be good to fix it because there is no workaround possible at the moment.
opened 11:46AM - 11 Feb 20 UTC
enhancement
Ruby API
SketchUp
### SketchUp Ruby API Feature Request
#### Request for new [`UI::HtmlDialog`]… (http://ruby.sketchup.com/UI/HtmlDialog.html) class instance methods:
**`#set_on_focus`**
**`#set_on_blur`**
These methods would be block form methods that register a proc/block to be called when the CEF window receives focus and loses focus (respectively.)
Background: The `window` object has limitations from within JavaScript running in a CEF instance, two of which are that the `onfocus` and `onblur` events do not fire for the window (and the Chrome Dev Tools do not show attached EventListeners on the `window` object.)
The CEF API appears to have: [`Class CefFocusHandler`](https://magpcss.org/ceforum/apidocs3/projects/(default)/CefFocusHandler.html) ... but appear to not be implemented for the SketchUp API [`UI::HtmlDialog`](http://ruby.sketchup.com/UI/HtmlDialog.html) class.
The scenario where data needs to be updated in a HtmlDialog needs to know when the dialog receives focus in order to know that the data should be updated. (Imagine that the user has left the dialog and is making changes that effect the displayed data. This might be done say in a model window that holds the focus until it is closed. If the HtmlDialog was the previous window with focus it receives the focus again, but a JS listener on `window.onfocus` is a noOp.
----
_REF:_
SketchUp public forum topic: [Focus event on window object from CEF HtmlDialog Javascript?](https://forums.sketchup.com/t/limitations-on-window-object-from-cef-htmldialog-javascript/115945/3)
----
CEF API: [`Class CefFocusHandler`](https://magpcss.org/ceforum/apidocs3/projects/(default)/CefFocusHandler.html)
> **re MacOS:** [CEF Issue 298, comment 1](https://code.google.com/p/chromiumembedded/issues/detail?id=298#c1)
>If you need notification when focus changes between different NSWindows it will be necessary to provide handlers for NSWindowDidBecomeMainNotification, NSWindowDidResignMainNotification and similar notifications (see chrome/browser/app\_controller\_mac.mm for an example). This will also be necessary to properly remove focus from the BrowserWebView (for instance, to gray out focused input fields) when focus moves to a new NSWindow.
1 Like