SketchUp v2016 steals focus from webdialog


#1

I have s small plugin that allows me to group a selection and type in a custom name OR choose a name from a dropdown list. At the start of the tool the textbox is activated with
document.getElementById("textbox").focus();

In V15 it works as intended. In V16, SketchUp often steals focus while I’m typing and then the keypresses are activating tools. Is there any way to prevent SketchUp to steal focus?


#2

Just noticed the same behavior with ThomThom’s Editable Text plugin and a few more of my own plugins using a webdialog with some sort of input text option. They all suffer from this.

  1. Move the mouse off the webdialog and the focus is gone and whatever you’re typing is firing keypress shortcuts.
  2. Even without moving the mousecursor off the webdialog, the window can loose focus and you’re firing shortcuts again.

Strange nobody else is reporting this as well. It would be very very nice if this can be resolved somehow OR if some javascript/ruby code could prevent this.


#4

This is really issue with long selection boxes that extend beyond the size of a webdialog.

I have had to modify my plugin especially for SU2016, although I don’t use webdialogs. The change is related to the new Trays, but I don’t know whether the behaviour can be modfied.


#5

It would be very bad for plugin any developer who has to use a webdialog for their plugin if there is no way around this problem. The modification to your plugin for V16 was related to this problem?


#6

I noticed this with my plugin as well. It’s especially annoying when you have a text box that you need to type in and then mouse moves away from the window while you are trying to type.


#7

I wonder if it is an OS related issue as I see it in other applications too (Revit comes to mind first). Archicad has an annoying feature of cutting off your typing if you don’t press the keys fast enough.

Anssi


#8

I would be very surprised if its an OS related issue. V15 doesn’t have the same issue AND some scripts can be ‘fixed’ for V16 by re-focussing:

In the body of the html add

<body onblur= go_focus();>

and in the Javascript add:

function go_focus(){
  document.getElementById("textbox").focus();
}

This would refocus to the textbox if focus gets lost to SketchUp while typing. The bad part is, it doesn’t seem to work in my more complex scripts. Don’t know why - didn’t have the time to find out. Still hoping for an official solution.


#9

@maxB, did you try setting a fixed width to the input box as @Tomasz inferred…

I think is OS related in as far as it’s a ‘Windows OS Trays’ issue which is new to v16…

john


#10

Hi John, a bit too busy at the moment. Still have to try. Hoping to find some time in the next week.


#11

Yes. I have had a tool re-activating, but in a different mode. This was happening because my plugin window was loosing focus and getting it back right afterwards.


#12

We have the same problem here at Modelur. Hope that SketchUp team fixes this in the next release. In the meanwhile we are thinkgin to solve this by using

webdialog.bring_to_front

method once cursor is out of the WebDialog. In brings it back to front and stays this way until something is clicked in 3D model or elsewhere… Hope it helps someone…

Best,
Jernej