We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Using CTRL to prevent docking behavior

I''m trying to reproduce the Visual Studio .NET docking behavior where while dragging a dockable window, you can press CTRL to prevent docking behavior. Pressing CTRL doesn''t change the state to Floating, but as long as you have CTRL held down, the control will not dock. If you release CTRL while dragging, then the docking behavior kicks in again and the window can be docked. Very useful when creating a layout. I''m trying to reproduce this behavior using Syncfusion Docking package. So far, I am listening on the DockingManager.DragFeedbackStart and DragFeedbackStop events. During the start event, I register the DM.ActiveControl.KeyDown and KeyUp events. When the KeyDown fires, I check to see if the CTRL key is pressed, if it is, I call the DM.SetFloatOnly passing in the active control and true. This works pretty well, but what I''m finding is that the first time you call the SetFloatOnly method while dragging the dockable window, the window will jump to the last float state and the drag operation is canceled. Is there any other way to temporarily prevent the docking behavior for a dockable window? Perhaps some property that or method that is not directly exposed via the DockingManager?

2 Replies

AD Administrator Syncfusion Team October 22, 2004 09:27 AM

Hi Chad, Your approach is correct. You can maintain a book variable that maintains the state of CTRL. Then you can preform the check in DockAllow event handler and then prevent docking from taking place. private void dockingManager1_DockAllow(object sender, Syncfusion.Windows.Forms.Tools.DockAllowEventArgs arg) { //Check if the Dragged control is floating. if(this.dockingManager1.IsFloating(arg.DragControl)) { //Check state of CTRL if(ctrlToggle) { arg.Cancel = true; } } } Please let me know if you have any questions. Thanks. Best regards, Stephen. >I''m trying to reproduce the Visual Studio .NET docking behavior where while dragging a dockable window, you can press CTRL to prevent docking behavior. > >Pressing CTRL doesn''t change the state to Floating, but as long as you have CTRL held down, the control will not dock. If you release CTRL while dragging, then the docking behavior kicks in again and the window can be docked. Very useful when creating a layout. > >I''m trying to reproduce this behavior using Syncfusion Docking package. So far, I am listening on the DockingManager.DragFeedbackStart and DragFeedbackStop events. During the start event, I register the DM.ActiveControl.KeyDown and KeyUp events. When the KeyDown fires, I check to see if the CTRL key is pressed, if it is, I call the DM.SetFloatOnly passing in the active control and true. > >This works pretty well, but what I''m finding is that the first time you call the SetFloatOnly method while dragging the dockable window, the window will jump to the last float state and the drag operation is canceled. > >Is there any other way to temporarily prevent the docking behavior for a dockable window? Perhaps some property that or method that is not directly exposed via the DockingManager?


CA Chad Allen October 22, 2004 10:21 AM

Thanks for your response. This appears to work, with one (fixable) exception. If the dragged control is docked before the first drag begins, the isFloating condition will be false during the initial drag, and thus the CTRL behavior won''t kick in. After you drag the docked window to a floating position, the CTRL code will work during the *next* drag. I simply removed the check to see if the dragged control is floating. Do you see any problem with this? Thanks, Chad >Hi Chad, > >Your approach is correct. You can maintain a book variable that maintains the state of CTRL. Then you can preform the check in DockAllow event handler and then prevent docking from taking place. > >private void dockingManager1_DockAllow(object sender, Syncfusion.Windows.Forms.Tools.DockAllowEventArgs arg) >{ >//Check if the Dragged control is floating. >if(this.dockingManager1.IsFloating(arg.DragControl)) >{ > //Check state of CTRL > if(ctrlToggle) > { > arg.Cancel = true; > } > } >} > >Please let me know if you have any questions. Thanks. > >Best regards, > >Stephen. > >>I''m trying to reproduce the Visual Studio .NET docking behavior where while dragging a dockable window, you can press CTRL to prevent docking behavior. >> >>Pressing CTRL doesn''t change the state to Floating, but as long as you have CTRL held down, the control will not dock. If you release CTRL while dragging, then the docking behavior kicks in again and the window can be docked. Very useful when creating a layout. >> >>I''m trying to reproduce this behavior using Syncfusion Docking package. So far, I am listening on the DockingManager.DragFeedbackStart and DragFeedbackStop events. During the start event, I register the DM.ActiveControl.KeyDown and KeyUp events. When the KeyDown fires, I check to see if the CTRL key is pressed, if it is, I call the DM.SetFloatOnly passing in the active control and true. >> >>This works pretty well, but what I''m finding is that the first time you call the SetFloatOnly method while dragging the dockable window, the window will jump to the last float state and the drag operation is canceled. >> >>Is there any other way to temporarily prevent the docking behavior for a dockable window? Perhaps some property that or method that is not directly exposed via the DockingManager?

Loader.
Live Chat Icon For mobile
Up arrow icon