I've created a PopupMenuTool with some attached buttons on a ribbon bar. I want to be able to drag & drop items onto said buttons. However, having picked up the drag event on the PopupMenuTool and called DropDown to open it successfully, I can't seem to find how to then get a drag/drop/mouseover/anything event on the buttons. Is this possible?
You can try to use the MouseEnterElement event on the toolbars manager and get the context of the entered element to see if it was a tool:
ToolBase enteredTool = (ToolBase)e.Element.GetContext( typeof( ToolBase ), false );
if ( enteredTool != null ){ // ...}
However, this will not work if you are dragging from a control which takes capture of the mouse when the mouse button is down. If that is the case, you would need to find the tool under the mouse in the mouse move of the control dragged from:
private void button1_MouseMove( object sender, MouseEventArgs e ){ Point screenLocationOfMouse = this.button1.PointToScreen( e.Location ); ToolBase toolUnderMouse = this.ultraToolbarsManager1.ToolFromPoint( screenLocationOfMouse );
if ( toolUnderMouse != null ) { // ... }}
Yes, the latter is true but the design is such that the candidate dropdown buttons are only some amongst several other possible drop targets, which otherwise work using DoDragDrop & the dragenter event. In the absence of a similar event for dropdown buttons on a ribbon bar, it's difficult to see how this can work. Is there really no other work-around, or could this be implemented?