Trent, this is a whole lot of information, but I'm not able to follow it completely. Is this a script that you wrote? And, definitely the script is causing the problem, because without the script running everything is OK? When you start messing with mouse and keyboard notifications, it is definitely possible to cause some unusual behavior. It might be necessary to analyze your code in order to provide any ideas.
Thanks Russ. I understand, I’m not even sure how to explain it.
This is by far the most complex and complicated script I ever programmed in order to accomplish one task. I originally created the plugin with the FDK back in 2004 and then recreated it with ExtendScript 3 years ago. I never saw the problem when I was developing it because I never undocked my structure view panel.
I suspect that the cause is in one of 3 areas - the notifications, the menu, or the window that's created. I don't understand how the structure view panel being docked or undocked would have anything thing to do with this, but I'll ignore that for now.
The notifications PostOpenDoc, PostActiveDocChange, and BackToUser are enabled from the start.
PostOpenDoc – If structured document and correct StructuredApplication, then enable Pre & PostMouseCommand, PostInsertElement, PostChangeElement, and PostSetAttrValue notifications. Also loads the documents main list of model numbers into a model list array, prepares the window, and sets various doc object properties.
PostActiveDocChange – For when the user has more than one document open and switches between them, does the same as PostOpenDoc does. Prevents the notifications when document is not structured or different structured application.
BackToUser – Turns on or off the Pre & PostMouseCommand, PostInsertElement, PostChangeElement, and PostSetAttrValue notifications based on whether the current position/selection is in the main flow of structure tree or not.
PreMouseCommand – Determines whether mouse action was a left click, right click, or double click; and whether mouse action was on element or insertion point. If mouse action was a double click, determines whether the current element is a container for model elements to open the window.
PostMouseCommand – If mouse action was a single left click, determines what element is selected. If the mouse action was a double click on a model container element, show window.
PostInsertElement – If element inserted is a container for model elements, show window. If the element inserted is in the documents main model list, the models are reloaded into the model list array.
PostChangeElement – If the element changed is in the documents main model list, the models are reloaded into the model list array.
PostSetAttrValue – If the user changed the model number in the attribute value for one of the model elements in the documents main model list, the models are reloaded into the model list array.
Each event is occuring at the correct time and correct order.
The enable/disable menu command enables/disables the Pre & PostMouseCommand, PostInsertElement, PostChangeElement, and PostSetAttrValue notifications; and is used in some conditional statments in PostOpenDoc, PostActiveDocChange, and BackToUser.
The window is created, but not shown until it's needed. Could that have something to do with it?
So if I add the following in the BackToUser notification, keyboard shortcuts work:
GVdoc.IsInFront = true; //GVdoc = app.ActiveDoc object reference for the current document
Take the line out, keyboard shortcuts stop working as described in the initial post. I'm not sure if it's a fix for the problem or covering it up.
Anyone have any thoughts?
1 person found this helpful
[edited, accidentally hit Ctrl+S again before I was finished. I hate that shortcut!]
Sorry for the delay on this. I needed a minute to review all the information.
Although I can't possibly know anything for sure without a deeper analysis, I suspect that you have fixed the problem. And, I do think that the Structure View being docked vs. undocked is significant. In the object model, the Structure View is represented as an open document object. In other words, if you iterate through all open documents with your code, you'll eventually get to the Structure View. It has an empty Name property but the Label property is "Structure View". Anyway, you can't make it the app.ActiveDoc, but you can capture it as a document object. If you've been working with FM for a long time, you might know this already, or at least recognize how this quirk makes some sense when you think about the old Structure View, back in the day.
Anyway, my guess is that somehow you might be getting the focus locked on the Structure View, rather than the original doc, with all the fancy operations you are doing. Then, your shortcuts stop working right, because the Structure View isn't really a document per se. When you toggle the entire application focus to the Windows desktop and back, FM correctly restores focus to the active doc, but just one time before your code messes it up again. With your new GVdoc.IsInFront = true; line, you effectively restore the proper focus and all is well again.
Added to all that, maybe somehow the Structure View pod just works differently with regard to focus when docked vs. undocked. Maybe there is some holdover, backdoor way to accidentally (programmatically) give the Structure View focus when it is undocked. I don't know.
Anyway, these are all just my suspicions, mostly speculation based on experience. I hope it helps.
Thanks Russ, your answer did led me to the real cause. My solution of forcing the active doc resulted in other issues. I didn't have a chance to follow up because I was put on other hot projects right away.
Anyway, the problem was caused by the the dialog window I was creating. The window would be created, populated, and sized based on the ActiveDoc, but not shown. The objects in the window would be modified based on user navigation in the document and the window would be shown only when it was required. The window was always left with the focus every time the user would click in the document, even if the window wasn't shown. By eliminating the pre-loading and creation of the window, it's working fine. Since everything is put into arrays and collections before it's applied to the window (including size and position of the objects), the hard work is already done, so the window is now created and populated each time it's shown. There wasn't any noticeable difference in speed by not creating, sizing, and populating the window ahead of time. If this makes any sense...
For the last 8 years or so I only get to dabble in code for maybe a couple days here and there once every 4-6 months, the rest of the time is completely unrelated to any programming. Even when I am working with some code, it's constant interruptions and side tracks with non-programming stuff.