TreeControl and KeepFocus and asynchronous ....

Started by stephan_35, July 06, 2009, 03:06:52 AM

Previous topic - Next topic

stephan_35

Hello

I return with my problem TreeControl and KeepFocus.

During the TreeControl:

KeepFocus T should be able to make animations on the AutoCAD drawing (Change the scale of a block)
KeepFocus must be nil to access directly to the buttons of Autocad.

I just discovered a problem with the instruction KeepFocus very strange with the TreeControl:

"SetKeepFocus nil", Autocad recovers hand quickly, in fact one can immediately select a button in the menus.

"SetKeepFocus T" Despite the KeepFocus, Nothing has changed!

Indeed, during the event, checking the status of GetKeepFocus it returns the correct value.
However, it does not take effect until the next event.

I wonder if the behavior does TreeControl is not unusual, in fact, once inside, you can not access the menus and commands autocad ...

In the meantime, I used more KeepFocus, The only solution I have found is to force the focus to another button of my dialog box to exit TreeControl ....

Best regards
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

stephan_35

Hello,

So, i think i have to change the title of topic ....

I join an example to explain what append : the first right cliq set KeepFocus to T but no change "real" KeepFocus", you have to right cliq again ....


Thanks
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

I cannot reproduce this problem (or maybe I just don't understand it). I'm testing with AutoCAD 2007 on Vista.
Owen Wengerd (Outside The Box) / ManuSoft

stephan_35

In fact, with KeepFocus T , when you have selected an item inside tree, you can not select directly an autocad menu or button inside menu, you have to set KeepFocus nil !

My example change the keepfocus state with mouse's right ou left button inside tree.

First step , change KeepFocus T to nil take effect immediatly.
Second step, change KeepFocus nil to T does not take effect immediatly ! but ready for next event !

So, i found why, is asynchronous is change to 0, all work perfectlty, but , because i need to access to autocad drawings command asynchronous is need to be 1.

I can put a video as you wish !

Best regards
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

I did not see the behavior you describe, but this is consistent with the asynchronous event handling. Especially on a slow computer, the event may not be handled until long after it is triggered.
Owen Wengerd (Outside The Box) / ManuSoft

stephan_35

Yes, i hope i understand asynchronous event ....  ;)

But i can not understand why "KeepFocus nil" is apply immediatly and why "KeepFocus T" doesn't !

http://www.ad-informatique.net/pages/posts/opendcl---treecontrol-and-keepfocus-and-asynchronous26.php?g=7

Bests regards

OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

I suspect that when KeepFocus = true, the event handler does not execute until the control gives up focus. Clicking outside the form would cause the queued event handler to run. I will investigate more with the sample you provided to see if I can reproduce the problem when the form is floating. In my first test, it was docked.

In the meantime, you mentioned before that everything works when handling events synchronously. As a workaround, you can change Event Invoke to Synchronous, and just put your (command) calls in a secondary function that get invoked from your event handler via (dcl_SendString). If that doesn't work, you might try calling (dcl_SetCmdBarFocus) in the form's OnMouseMovedOff event handler.
Owen Wengerd (Outside The Box) / ManuSoft

owenwengerd

To reproduce the problem, if I understand correctly:

1) Load the test app.
2) Left-click on the tree control (setting KeepFocus false), then move the mouse off the form.
3) Right-click on the tree control (setting KeepFocus true), then move the mouse off the form.
4) Right-click on the tree control (setting KeepFocus true again -- i.e. no change), then move the mouse off the form.

The "problem" is that after step 4, the tree control keeps the input focus, and the AutoCAD window does not get it back until you click somewhere. This is working as designed. This is exactly what "Keep Focus" is designed to do: allow keyboard input to go to the control rather than AutoCAD by capturing the input focus.

What makes it appear inconsistent is the fact that the behavior after the first right-click is different from the second right-click. The reason is that, with Event Invoke set to asynchronous, the first right-click does not set Keep Focus to true until *after* AutoCAD has already retaken the focus. Thus the new KeepFocus setting has no effect because the damage is already done. But by the second right-click, AutoCAD never retakes the focus, so the new setting works as expected.

When Event Invoke is set to Synchronous, the Keep Focus change occurs immediately, so it changes *before* AutoCAd retakes the focus, and thus the effect is seen after the *first* right-click.

I hope this explains the behavior. In any case, I do not see a bug here.
Owen Wengerd (Outside The Box) / ManuSoft

stephan_35

Hello

The "dcl_SendString" runs correctly, but no animation on the screen.

I found a solution to my problem, simple, but it had to be found: (dcl_Control_SetFocus TREE)

Longer need to use keepfocus.
we set asynchronous to 1.

However, I remain confused to see that the management of a treecontrol causing as many problems related to focus.

Best regards
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql