How to know when dragging a tab has finished? - google-chrome-extension

I am building a Chrome extension that moves my pinned tabs to the active window: http://screencast.com/t/bRroTVda
It works great, with one exception:
When switching to another Chrome window by clicking on a tab in that window, I can't use chrome.tabs.move to move my pinned tabs to the newly activated window. runtime.lastError in the callback says
Tabs cannot be edited right now (user may be dragging a tab)
My problem now is: There seems to be no event that I can subscribe to that is raised when the user stops dragging.
What are my options?

You could retry moving tabs until the error goes away. To rate-limit the number of calls to 10 per second, use setTimeout(yourFunctionThatCallsChromeTabsMove, 100);.

Related

My web page moves back and forth automatically while open magnifier with 200%

I have a web page, when I click one button(by both using mouse click or using keyboard with tab and press), it will show some items, normally, it works perfect.
However, if I
1> open windows magnifier with 200%,
AND
2> use keyboard with tab and press
to trigger the button,
the items still shows correctly,
but the whole page moves back and forth in horizon automatically until I move mmouse or press any key.
++++++
I got the root cause:
As I input the follow code
document.addEventListener('focus',
function()
{ console.log('focused: ', document.activeElement)
},
true);
in console to monitor the focused element,
it shows the focus are switch between two elements,
however, I try to set the two element with tabindex = 0 or -1,
and all the 4 combinations,
but it doesn't work.
Are you using "docked", "full screen", or "lens" view for the magnifier?
I'm guessing "full screen" because in that mode, as you tab through a page, the magnifier will try to keep the keyboard focus within view. You might have an issue where your focus is moving between two elements that both can't be displayed in the magnifier at the same time. Usually it will just move the magnifier to the element that has focus.
I'd suggest trying "Docked" and "Lens" view first to see if you still have an issue.

Can you detect moving between open tabs in different Windows?

Using background.js in a Chrome Extension can you detect the focus moving from one tab to another?
I'm talking about a very specific situation - not just using onactivated to detect that the user has clicked a different tab.
If I have two Chrome windows open (same user account), each with a different webpage showing, and the user simply clicks to bring one to the front (so you can scroll and read the page), the onactivated event does NOT fire. It only seems to fire if you move between tabs in a single window.
I can capture mousedown etc, but if you just click once to bring a window to the front these events don't fire either (a second click fires mousedown).
Seems a strange oversight...I would have thought onactivated would cover this scenario - the user, they've activated it.
In fact, onactivated doesn't fire when you click that second time. I guess it's specific to switching tabs in a single window.
chrome.tabs.onActivated fires when the active tab in a window changes [docs], meaning it's per window so it won't fire unless the user switches to a different tab within that tab's window.
Solution: use chrome.windows.onFocusChanged that fires when a Chrome window is activated [docs].
Reports chrome.windows.WINDOW_ID_NONE if all Chrome windows have lost focus. Note: On some Linux window managers, WINDOW_ID_NONE is always sent immediately preceding a switch from one Chrome window to another.
chrome.windows.onFocusChanged.addListener(windowId => {
// do something
});
You can specify the type of windows to report:
chrome.windows.onFocusChanged.addListener(windowId => {
// do something
}, {windowTypes: ['normal']});

Force tab to render

Is there a way to force a certain tab to render, even without currently being the active tab?
The reason i need to do this is because my extension uses chrome.tabs to open multiple tabs and switch between them, and whenever I switch to a tab which has not yet been active, the tab has not rendered yet, which causes a white flash to appear on the tab until the tab renders. The duration of the white flash is also proportional to how heavy the web page is to render.
What I've noticed though, is that if you switch to a tab which was active at least once in the past, the white flash does not appear (since it has been rendered at least once in the past)
I need to force a tab to be rendered before switching to it, so that the white flash doesn't appear.
I am writing on chrome version 38 (due to technical restrictions)
Thanks
No. You can't control it.
The white flashing is indeed an annoying known issue.
The only wild idea that can be implemented right now:
create a new minimized window with a blank url or about:blank,
move the tab you need into that window via chrome.tabs.move
now that the tab is active Chrome should render it even in a minimized window
then after a while move the tab back and activate it

Why is Excel / Word 2013 starting invisible?

Our Company recently upgraded to Office 2013 since we want to use SharePoint 2013.
We had several issues with the new Office Version but Microsoft has already solved some of them.
Anyways, one thing sitll grinds my gears:
Excel or Word sometimes starts invisible. It is visible in the Taskbar but the window doesnt pop up. I can click on the Icon in the taskbar but it doesn't change anything. The only way i figured out to show the window, is to use [Windows] + [Arrow Keys].
I can't tell the constellation why this is happening but most of the time it is if there isn't already another instance of the program running.
I don't have Office 2013 at home to reconstruct this but I have seen this on different Computers at our Office.
Now does anybody know about this issue?
What can I do about it?
Is it known to Microsoft?
Any help is appreciated.
I don't think that it's invisible, it's just starting off screen somewhere. Perhaps on a second monitor that is no longer there (or moved virtually to the other side). The [Windows] + [Arrows Keys] just moves the window onscreen where you can see it.
Alternatively, you could hover the mouse over the icon on the task bar, right click on the preview window and then select Move (if Move is grayed out, select restore and repeat). Then, hit any [Arrow Key] (this will attach your mouse to the window caption bar) then move your mouse (without clicking anything) until the window shows up on screen.
By doing this you can figure out what side of the screen the application is opening up (not that knowing helps much). Excel should just show up where ever you had it last, but it will not remember it's location if you snap it to the sides or top of the screen (which is what you were doing); It will only remember the Normal View size and position of the window.
My workaround for this bug is to click the Taskbar icon for the new (invisible) window while it's active, which minimizes the window, then click it again to restore it. Then it becomes visible.
I have the same issue, and it's definitely an invisible window, not off-screen (see workaround below).
It only happens in specific circumstances: when opening a second word doc from a sharepoint/office 365 location, the second doc gets a taskbar icon, but no visible content, so the first doc is still visible (but the second doc is invisibly in front of it).
The workaround is to click the minimise button on the first doc. Nothing will appear to happen because it's the invisible second doc window that receives the click event. Then select the icon on the task bar to make it reappear, properly visible.

Move command in Dialog based aplications

I working on Dialog based applications once i right click on the Dialog Title bar a drop down list is coming with two options 1. Move and 2. Alt+F4 close. Once the User Press Move and he can able to drag the window as he desired and I add the On NC Hits Test to stop dragging its stopping normal dragging but it is not working in this particular context can any body help me in fixing this Bug.
When the user use the keyboard interface, he can move a windows with the arrow keys, without using the mouse.
If you want to limit the position of your dialog, process the WM_MOVING message.

Resources