+2009-06-16 Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+ * ToolBar.cs: Expose as internal the code used to show a dropdown menu.
+ * PrintPreviewDialog.cs: Handle the down/up arrow keys for our
+ DropDown element.
+ Fixes #509152.
+
2009-06-16 Ivan N. Zlatev <contact@i-nz.net>
* DataGridView.cs: Scrolling fixes.
class PrintToolBar : ToolBar
{
+ bool dropdownmenu_visible;
+ ContextMenu dropdownmenu;
+
public int GetNext (int pos)
{
// Select the next button that is *not* a separator
switch (key) {
case Keys.Up:
case Keys.Down:
- return true; // Ignore.
+ // We know that this toolbar only has one DropDownButton
+ if (CurrentItem != -1 && items [CurrentItem].Button.Style == ToolBarButtonStyle.DropDownButton) {
+ if (dropdownmenu == null) {
+ dropdownmenu = (ContextMenu)(items [CurrentItem].Button.DropDownMenu);
+#if NET_2_0
+ dropdownmenu.Collapse += new EventHandler (OnDropDownMenuCollapse);
+#endif
+ }
+
+ if (!dropdownmenu_visible) {
+ items [CurrentItem].DDPressed = dropdownmenu_visible = true;
+ items [CurrentItem].Invalidate ();
+
+ ShowDropDownMenu (items [CurrentItem]);
+ } else
+ dropdownmenu.ProcessCmdKey (ref msg, key);
+ }
+ return true;
case Keys.Left:
case Keys.Right:
case Keys.Tab:
return base.InternalPreProcessMessage (ref msg);
}
+
+#if NET_2_0
+ void OnDropDownMenuCollapse (object o, EventArgs args)
+ {
+ dropdownmenu_visible = false;
+ }
+#endif
}
void CloseButtonClicked (object sender, EventArgs e)
if (e.Button.DropDownMenu == null)
return;
- ToolBarItem item = current_item;
+ ShowDropDownMenu (current_item);
+ }
+ internal void ShowDropDownMenu (ToolBarItem item)
+ {
Point loc = new Point (item.Rectangle.X + 1, item.Rectangle.Bottom + 1);
- ((ContextMenu) e.Button.DropDownMenu).Show (this, loc);
+ ((ContextMenu) item.Button.DropDownMenu).Show (this, loc);
item.DDPressed = false;
item.Hilight = false;