Skip to content

Commit

Permalink
- Disable default action, if this is a drop button and it is clicked
Browse files Browse the repository at this point in the history
- ButtonSpec's used to drop menu's if they had a context menu;

#1169
  • Loading branch information
Smurf-IV committed Nov 19, 2023
1 parent 06bae33 commit bf7053f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=======

## 2024-11-xx - Build 2411 - November 2024
* Resolved [#1169](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1169), Button Spec Krypton Context Menu (Canary)
* New adjusting the size of a `KryptonComboBox` also changes the `DropDownWidth`
- Note: The `DropDownWidth` can still be set independently from the `Size` property
* Resolved [#1091](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1091), Krypton File Dialogs Missing Buttons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,21 +379,18 @@ private void OnClick(object sender, MouseEventArgs e)
// Never show a context menu in design mode
if (!CommonHelper.DesignMode(Manager.Control))
{
var showMenu = false;
var performDefaultClick = true;
if (ButtonSpec is ButtonSpecAny { ShowDrop: true })
{
showMenu = ViewButton?.SplitRectangle.Contains(e.Location) ?? false;
performDefaultClick = !showMenu;
}

// ButtonSpec's used to drop menu's if they had a context menu;
// BUT; Disable default action, if this is a drop button and it is clicked
bool performDefaultClick = !(ButtonSpec is ButtonSpecAny { ShowDrop: true }
&& ViewButton != null
&& ViewButton.SplitRectangle.Contains(e.Location));

if (performDefaultClick)
{
// Fire the event handlers hooked into the button spec click event
ButtonSpec.PerformClick(e);
}

if (showMenu)
{
// Does the button spec define a krypton context menu?
if ((ButtonSpec.KryptonContextMenu != null) && (ViewButton != null))
Expand Down Expand Up @@ -444,7 +441,7 @@ private void OnClick(object sender, MouseEventArgs e)

private void OnKryptonContextMenuClosed(object sender, ToolStripDropDownClosedEventArgs e)
{
// Unhook from context menu event so it could garbage collected in the future
// Unhook from context menu event, so that it can garbage collected in the future
var kcm = (KryptonContextMenu)sender;
kcm.Closed -= OnKryptonContextMenuClosed;

Expand Down

0 comments on commit bf7053f

Please sign in to comment.