Setting commandlink text on commandupdate causes focus loss

Docking/MDI for Windows Forms Forum

Posted 17 years ago by Chien A.
Version: 2.0.91
Platform: .NET 2.0
Environment: Windows Vista (32-bit)
Avatar
This one gave me a real headache tracking down...

Attempting to set the text of a commandlink hosted on a PopupMenu (such as updating text for a command that toggles between 2 modes) during the CommandUpdate event of the BarManager causes the context menu to flash briefly in the top-left corner of the screen on popup, and more importantly also causes the currently focused toolwindow/window to become unfocused - which effectively breaks all context/selection specific updating.

Can be replicated by inserting:

If e.Command.FullName.Equals("Edit.Copy") Then
e.CommandLink.Text = e.Command.Text + " Test"
End If

into the barManager_CommandUpdate handler of barForm.vb in the demo project (minimise MDI window so you can see the window frame lose focus).

[Modified at 07/09/2007 12:41 AM]

Comments (3)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Oddly enough, a call to Screen.FromControl (during the layout caused by your text change) seemed to be forcing the popup menu to be made visible prematurely. We changed this call to Screen.FromRectangle instead and that has seemed to have fixed the issue. This change will be in the next maintenance release.


Actipro Software Support

Posted 17 years ago by Chien A.
Avatar
Just in case, I am also seeing this behaviour when trying to change the visibility of a command link during the CommandUpdate event - it sounds like it might be caused by the same thing and therefore is fixed by the above, but good to confirm.

Also, I checked on an XP comp as well and the same thing happens there.
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes the fix handles that scenario too.


Actipro Software Support

The latest build of this product (v24.1.0) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.