WinUI: IsContextualClick always returns False in TextField.MouseDown

Hi everyone,

I’ve encountered a bug when WinUI is enabled in a Desktop project. It seems that the IsContextualClick property consistently returns False during the MouseDown event of a TextField, even when using a right-click.

Is there a workaround?

Thanks.

Unfortunately the only workaround for now is to add a DesktopXAMLContainer with an assigned TextBox control, then you can handle the PointerPressed event (via EventTriggered) to determine what button was pressed. You can also handle the ContextRequested event if all you were looking for was a way to disable the contextual menu.

https://tracker.xojo.com/xojoinc/xojo/-/issues/81329

2 Likes

Actually, depending on what you’re trying to do, you could also handle the ConstructContextualMenu event as a way to detect a right-click. Just keep in mind that this event can also be triggered by certain keyboard shortcuts or special key presses.

Thanks, William. The main issue is that since I started using WinUI, some of my custom classes have lost or changed their functionality. In this particular case, I was using the click type to trigger different RaiseEvents.

I’ve already implemented a workaround, but a formal fix is definitely necessary.

Thanks a lot! I see you’ve already looked into it! :grey_heart: :clap: