View Issue Details

IDProjectCategoryView StatusLast Update
0002423NoesisGUIC++ SDKpublic2022-11-07 17:13
Reportersatorp Assigned Tosfernandez  
Status feedbackResolutionopen 
Product Version3.1.3 
Target Version3.1.7 
Summary0002423: Clicking on Button control may leave it in a invalid mouse capture state
DescriptionSince the ValidationRules feature in WPF has not been supported yet, we try to implement our own validating system for TextBox input. Basically it works by validating the input on LostFocus and if validation fails it will report the error and set the focus back to the TextBox. But we have the following issue when we use it on a dialog:

1. User enters an invalid input on TextBox
2. User clicks on a button control (the focus shifts to the button)
3. Validation runs (on TextBox LostFocus), and set the focus back to the TextBox
4. The button seems to have the mouse capture even though it has no focus. Clicking anywhere on the dialog will trigger the button's click.

It seems that there might be an issue in the implemetation of BaseButton::OnMouseLeftButtonDown, where it calls Focus on itself, and proceeds to capture the mouse without checking if the call to Focus is succesful. We have a patch to fix the issue (see attachment), but we're not sure if the original behavior is indeed intended, or if there's a better a solution.

It will also be nice to see the validation features in WPF implemented in the future.
TagsNo tags attached.


related to 0001244 assignedsfernandez Noesis should support ValidationRules per xaml 




2022-09-16 09:32


BaseButtonMouseDown.patch (613 bytes)   
--- Native/Src/Packages/Gui/Core/Src/BaseButton.cpp	Thu Jul 29 17:11:59 2021
+++ trunk/Noesis/Native/Src/Packages/Gui/Core/Src/BaseButton.cpp	Wed Aug 24 16:52:18 2022
@@ -301,7 +301,14 @@
     if (GetClickMode() != ClickMode_Hover)
-        Focus();
+        bool b = Focus();
+        if (!b && GetFocusable()) {
+            // Only capture mouse if Focus() fails
+            e.handled = true;
+            ParentClass::OnMouseLeftButtonDown(e);
+            return;
+        }
         if (e.leftButton == MouseButtonState_Pressed)
             if (CaptureMouse())
BaseButtonMouseDown.patch (613 bytes)   


2022-09-26 13:09

manager   ~0008084

Hello, checking with WPF it seems our behavior is the same. The Button keeps the mouse capture until you release the left mouse button. At that moment the Button will release the mouse capture and rise the Click event, even if the focus was already set to the TextBox. Later clicks won't be redirected to the Button.
Isn't that the behavior you are seeing?

Issue History

Date Modified Username Field Change
2022-09-16 09:32 satorp New Issue
2022-09-16 09:32 satorp File Added: BaseButtonMouseDown.patch
2022-09-20 11:59 sfernandez Relationship added related to 0001244
2022-09-20 12:00 sfernandez Assigned To => sfernandez
2022-09-20 12:00 sfernandez Status new => assigned
2022-09-20 12:00 sfernandez Target Version => 3.1.6
2022-09-26 13:09 sfernandez Status assigned => feedback
2022-09-26 13:09 sfernandez Note Added: 0008084
2022-11-07 17:13 sfernandez Target Version 3.1.6 => 3.1.7