nikobarli
Topic Author
Posts: 178
Joined: 26 Apr 2017, 06:23

Event is missing after invoking a modal dialog (MessageBox) ?

22 Aug 2017, 12:00

Hi,

To demonstrate the strange thing I observed, I modified the Tutorial05 source code included in the C++ SDK (Src\Samples\D3D11\Tutorial05).

I added the following 3 lines into Tutorial05.cpp to spawn a modal MessageBox anytime mouse is down inside the root grid.
        ...
        // Loads XAML and creates a view with it
        Ptr<FrameworkElement> xaml = Noesis::GUI::LoadXaml<FrameworkElement>("PasswordBox.xaml");
        g_XamlView = Noesis::GUI::CreateView(xaml.GetPtr());
        g_XamlView->SetSize(g_Width, g_Height);
        g_XamlView->SetAntialiasingMode(Noesis::Gui::AntialiasingMode_PPAA);

        // Added 3 lines of code here, to show a modal message box anytime the mouse is downed
        xaml->MouseDown() += [](auto sender, auto args) {
            ::MessageBox(g_hWnd, L"test", L"test", MB_OK);
        };

        // Initializes renderer. This could be done in a render thread
        Ptr<RenderDevice> device = *new D3D11RenderDevice(g_pImmediateContext);
        Ptr<VGContext> context = Noesis::GUI::CreateVGContext(device.GetPtr(), Noesis::VGOptions());
        g_XamlView->GetRenderer()->Init(context.GetPtr());
        ...
The weird behavior I observed is as follows:

1. Run Tutorial05.exe
2. Click anywhere inside the password box -> MessageBox is shown as modal dialog
3. Click "OK" to close the dialog
4. Click anywhere inside the password box -> MessageBox is not shown ??
5. Click anywhere inside the password box -> MessageBox is shown as modal dialog

I wonder why the MessageBox is not shown in step 4 above. Is there something wrong with the integration layer ?
 
Wanderer
Posts: 168
Joined: 08 May 2017, 18:36

Re: Event is missing after invoking a modal dialog (MessageBox) ?

23 Aug 2017, 13:15

I not test it, but in my oppinion, if MessageBox is new window and you close this MessageBox, Noesis Windows is not focused, and when you click on area, you only focused window in point 4. This is maybe reason why not MessageBox is not showed.
 
nikobarli
Topic Author
Posts: 178
Joined: 26 Apr 2017, 06:23

Re: Event is missing after invoking a modal dialog (MessageBox) ?

24 Aug 2017, 03:10

The problem doesn't happen when I moved the focus to other windows, i.e.
1. Run Tutorial05.exe
2. Click to any other window to move the focus
3. Click anywhere inside the password box -> MessageBox is shown as expected

I also observed the followings.
If the ::MessageBox's first parameter to nullptr (::MessageBox parent is the desktop window) then the problem disappears.

Another observation is that Button's Click event is not affected by this issue. I modified PasswordBox.xaml to add a name to the login button ("Button").
Then changed the code behind as follows:
        auto button = xaml->FindName<Button>("Button");
        button->Click() += [](auto sender, auto args) {
            ::MessageBox(g_hWnd, L"test", L"test", MB_OK);
        };
Then it works as expected.

1. Run Tutorial05.exe
2. Click login button -> MessageBox is shown as modal dialog
3. Click "OK" to close the dialog
4. Click login button -> MessageBox is shown as modal dialog
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Event is missing after invoking a modal dialog (MessageBox) ?

24 Aug 2017, 11:54

I think the problem is that when showing the MessageBox in MouseDown event, MouseUp event is not received by the View, and we are discarding consecutive MouseDown events without its corresponding MouseUp.
When you show the MessageBox in Click event, both MouseDown and MouseUp events have occurred, and that is why it works as expected.

Try calling view->ResetInputState() before or after MessageBox is shown and it should work.
 
nikobarli
Topic Author
Posts: 178
Joined: 26 Apr 2017, 06:23

Re: Event is missing after invoking a modal dialog (MessageBox) ?

29 Aug 2017, 05:12

I think the problem is that when showing the MessageBox in MouseDown event, MouseUp event is not received by the View, and we are discarding consecutive MouseDown events without its corresponding MouseUp.
When you show the MessageBox in Click event, both MouseDown and MouseUp events have occurred, and that is why it works as expected.
Ok, I see the reason.
Try calling view->ResetInputState() before or after MessageBox is shown and it should work.
I confirmed the workaround. Thanks !
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Event is missing after invoking a modal dialog (MessageBox) ?

30 Aug 2017, 13:00

Great, glad to help :)

Who is online

Users browsing this forum: Bing [Bot] and 0 guests