Comments (8)
So after a lot of back and forth and checking the Git change log I tracked this down to a change in the app.manifest
and the DPI settings that were recently changed.
Specifically this throws the menu into the wrong place (0 offset):
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<ws2:dpiAwareness>PerMonitorV2</ws2:dpiAwareness>
</windowsSettings>
</application>
If I comment out the the dpiAware settings then the menu works correctly:
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
<!-- <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<ws2:dpiAwareness>PerMonitorV2</ws2:dpiAwareness> -->
</windowsSettings>
</application>
This is very strange! Especially since there are many other context menus that essentially work the same as this one - the tab, editor and preview context menus are working just fine with the dpi settings enabled. It's only the FolderBrowser context menu that's affected. I suspect it's due to a control reference that maybe isn't valid or pointing at an element that doesn't have a context menu.
For now I've recompiled with the old manifest setting until I can figure out why that's failing.
Update should be in 2.9.7 shortly.
from markdownmonster.
So I spent a bit more time looking into this problem.
It seems this is caused by the fact that MM in the folder browser manually intercepts all mouse operations (due to the lousy mouse event handling inside of the native Treeview control). All of this resulted in multiple events firing and competing for the context menu event handling.
I ended up refactoring a bunch of the click handling code. It appears that the main difference is a timing and focus issue where if focus is not on the form and item exactly, the context menu jumps out. The ultimate fixes were two things:
- Removing explicit click handling of context menu items and let OnContextMenuOpening work.
- Explicitly delay opening the menu using a Dispatcher() call after focus is set.
In the end I was able to consolidate a bunch of right click handling code into something much simpler:
private void TreeViewItem_PreviewMouseDownClick(object sender, MouseButtonEventArgs e)
{
startPoint = e.GetPosition(null);
if (e.RightButton == MouseButtonState.Pressed)
{
var item = ElementHelper.FindVisualTreeParent<TreeViewItem>(e.OriginalSource as FrameworkElement);
if (item != null)
{
TreeViewSelection(item);
e.Handled = true;
}
TreeFolderBrowser.ContextMenu = FolderBrowserContextMenu.ContextMenu;
FolderBrowserContextMenu.ShowContextMenu();
}
}
And then for manually invoked menu:
public void Show()
{
ContextMenuOpening?.Invoke(this, ContextMenu);
if (ContextMenu != null && ContextMenu.Items.Count > 0)
{
Model.ActiveEditor?.SetMarkdownMonsterWindowFocus();
FolderBrowser.Dispatcher.Invoke(() =>
{
ContextMenu.IsOpen = true;
var item = ContextMenu.Items[0] as MenuItem;
item?.Focus();
}, DispatcherPriority.Background);
}
}
The key here is the dispatcher which ensures that the menu isn't shown until the editor/window has focus (even though we're not in the editor).
As a bonus the context menu now behaves much cleaner - it snaps into place without the previous flicker and occasional missed right click.
Sweet!
If all of this seems too custom: MM does a whole bunch of custom key and click handling and the default TreeView click and keyboard events don't offer enough granualarity to handle selection management. So there's a lot going on and it's often difficult to see all the interactions - this apparently was one of them with the thrown in curveball of the different behavior for the DPI setting.
The updated version now works with multi-monitor DPI enabled.
from markdownmonster.
It's a different version. Wait until 2.9.8. 2.9.7 has the basic fix via the manifest. 2.9.7.2 has the additional tweaks for the folder browser. I'll let these run for a few days before updating to 2.9.8.
You're the WinGet maintainer? I guess my frequent releases keep you busy, huh?
from markdownmonster.
Ugh - yes I see it too now...
Not sure what's causing this though - the folder browser code hasn't been touched in quite some time so not sure what changed in the context menu activation. I'll have to take a closer look.
from markdownmonster.
I'm looking forward to the arrival of a new version.
from markdownmonster.
2.9.7.2 now available for download
from markdownmonster.
@RickStrahl Is the download 2.9.7.2 version the same mmReleases 2.9.7 version?
Because I am used to downloading and installing from the mmRelease by Winget function. I maintain MM for Winget :-)
from markdownmonster.
- Understand. Then I will wait for 2.9.8 to test again. I will close this issue first.
- One small thing.
from markdownmonster.
Related Issues (20)
- Table Editor window opens at bottom of screen HOT 17
- Suggestion: ChangeLog link in Help menu HOT 1
- Cursor jumps with scroll sync set and preview closed HOT 1
- Not showing original file content when it has backup files HOT 11
- Document Outline unreadable in Dark mode HOT 9
- Feature Request. .ahk Autohotkey syntax highlight HOT 3
- Renaming file opens the file empty sometimes HOT 14
- Statistics in footer bar don't change when opening a file HOT 2
- When tab focus changes, change the focus in the file selector on the left as well HOT 3
- When creating a new file and pasting, the edit window width changes HOT 3
- Right-clicking a file should not open, should only show context menu HOT 7
- Repeated ctrl-f or ctrl-h should jump to next occurrence HOT 8
- Can open file multiple times HOT 5
- FB refresh icon shows selected when unselecting FB sync HOT 1
- Have a way to keep read-only files open in tabs (pin?) HOT 2
- Regression: mouse drag errors? HOT 1
- Different context menu after first opening MM HOT 1
- Renaminng renames wrong file HOT 2
- Problems with HTML preview HOT 2
- Feature Request: Improve Embed Link dialog (`Ctrl+K`) when clipboard contains HTML link HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdownmonster.