locked
Input from both CoreIndependentInputSource on SwapChainPanel and CoreWindow RRS feed

  • Question

  • Hello,

    I'm working on a DirectX and XAML app in which I need to catch pointer events on a SwapChainPanel and I need to catch key events on the CoreWindow. 

    I am creating a CoreIndependentInputSource on the SwapChainPanel and attaching the event handlers in a background thread. This works fine up until the call to

    Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);

    After this, my app no longer responds to keyboard input on the CoreWindow. So basically, it is letting me do one or the other but not both. How can I do both?

    Thanks for your help.

    David

    Friday, September 13, 2013 3:33 AM

Answers

  • Are you using the Windows 8.1 Preview build?

    I was able to reproduce this problem on the old Preview built, but it should work correctly in the RTM build.

    • Marked as answer by davidb353 Saturday, September 14, 2013 4:32 PM
    Friday, September 13, 2013 9:06 PM

All replies

  • CoreIndependentInputSource only supports pointer input, and keyboard input should always be delivered on the UI thread.

    What object is associated with the Dispatcher you're calling ProcessEvents on?  If it's the CoreWindow or a UI thread object then that might cause the behavior you're seeing.   Can you verify that you're only processing the event queue for the CoreIndependentInputSource object, and not the CoreWindow or another object?

    e.g. it should be something like:

    m_coreInput = swapChainPanel->CreateCoreIndependentInputSource(
    	Windows::UI::Core::CoreInputDeviceTypes::Mouse |
    	Windows::UI::Core::CoreInputDeviceTypes::Touch |
    	Windows::UI::Core::CoreInputDeviceTypes::Pen
    	);
    
    
    // attach event handlers..
    m_coreInput->PointerPressed += ....
    
    // Process input messages on CoreIndependentInput queue 
    m_coreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);


    Friday, September 13, 2013 7:24 PM
  • My code is just like what you have shown. The dispatcher is associated with the coreInput. The event queue for the coreInput object is definitely being processed, but as soon as I click once with the mouse, the app stops responding to keyboard input. So I think this verifies that only coreInput events are being processed. The key event handlers are attached to the CoreWindow on the UI thread. Mainly I just want to understand the behavior that I'm seeing.





    • Edited by davidb353 Friday, September 13, 2013 7:53 PM
    Friday, September 13, 2013 7:41 PM
  • Do you have a minimal project you could share that reproduces the problem?  What you're describing isn't intended behavior, and in my quick test keyboard input was still correctly being processed by the CoreWindow.
    Friday, September 13, 2013 7:50 PM
  • Yes, I do. Should I email it to you?
    Friday, September 13, 2013 8:02 PM
  • I added a single KeyDown event handler to the CoreWindow in the DirectX XAML project template in VS2013. 

    The handler shows a message dialog. It works until I press the mouse. After the mouse click, the key down message dialog won't pop up.

    Friday, September 13, 2013 8:04 PM
  • Are you using the Windows 8.1 Preview build?

    I was able to reproduce this problem on the old Preview built, but it should work correctly in the RTM build.

    • Marked as answer by davidb353 Saturday, September 14, 2013 4:32 PM
    Friday, September 13, 2013 9:06 PM
  • I'm using the preview build. This must be the problem. Any idea what was causing it?
    Saturday, September 14, 2013 4:34 PM