windows 8/10 store app: SetPointerCapture not working at all? - windows-8

As I understood CoreWindow::SetPointerCapture should do the same as the good-old win32-Clipcursor. Actually I found that it does pretty much nothing.
Anybody got this running ?

No, SetPointerCapture captures the pointer. Exact equivalent of the win32 SetCapture() function. It is the basic OS function you'd need to, say, reliably generate a Click or MouseUp notification for a button or ensure a popup window like a context menu is closed when the user clicks outside of it. You rarely have to call it yourself since most controls already take care of it by themselves.
Nothing to do with trapping the mouse into a box. ClipCursor() only exists in win32 because they made a mistake 29 years ago at Windows v1.0, trivially defeated today by pressing Ctrl+Esc. It was not carried forward into WinRT, you can't trap the user.

Related

Tab Order in Visual Studio hates me

Tab Order in Visual Studio does not work for me for some reason.
I am making a VB.NET plugin for a cad program called Rhinocreos 5.
I have everything set perfect, and I don't know what the cause of it is.
I am using .Show() instead of .ShowDialog(), because I need that thread open and I don't feel like doing any thread management (not paid enough lol)
Does anyone have any pointers for this? Has anyone else ran into a tab problem with Rhino5 and .NET?
EDIT**
Seems I have to use a MODELESS Form for a rhino plugin.... So I wont have any tab keys or arrow keys unless I do a hook. But since I need to make the plugin future proof (in case I am no longer working here), I won't be doing that either. But thanks for the answers, comments, and awesome downvotes.
Very difficult to guess what's going on from the information you have provided, but I'd check the following things in the following order:
The disobedient form is open and has focus.
The form has controls in it.
At least some of the controls are enabled, focusable have their TabStop set to true.
There is no low-level keyboard handling in action (PreviewKeyDown, hooks etc).
Finally I'd call ShowDialog() instead of Show(), passing main form as parameter (to make disobedient form a child of main form) and see if that makes a difference.
It was a modeless form inside of Rhino3D as a plugin.
Rhino3D uses all plugins in the main thread. So tab is not an option.
The workaround was to tag all controls with a tag work (I used "tabMe")
Then I store all the controls in a List myTabbyControls.
Each time I press tab, I would cycle through the list.
But thanks for the down votes. It's the running joke of SO.

Windows 8 Keyboard Connected event

Is there any API in Windows 8 that tells you whether there is a Keyboard connected to your device? I believe the OS should have information about this, but I am not sure that it is exposed.
I checked the Windows.Devices.Input.KeyboardCapabilities(). It only returns an object with a property keyboardPresent that equals to 1 on my touch device or non-touch device.
The problem has already been reported on stackoverflow without solution (Provide another solution but which also don't seem to work).
Maybe a work around could be to add a TextBox outside the screen and set the focus on it and register InputPane.GetForCurrentView().Showing and to see if it is fired or not. If it is you can deduce that there is no keyboard connected (and you might be able to reset the focus to the page inside the event so that the keyboard don't actually pop up) and if it don't fired that the there is a keyboard connected. That not a really good solution but might be the best available ...

ITfTextInputProcessor::Deactivate gets called unexpectedly on regaining focus

I am implementing a text service on windows. Things work fine. However when I shift window focus to another application and shift focus back to the original application, the selected text services gets de-activated (I notice a call to ITfTextInputProcessor::Deactivate). I think this call is unexpected. Post this call, The service has to be re-activated manually. I am surely doing something goofy. Just that I don't know what it is.
Offhand, I'd say that you are indeed doing something goofy. :) In particular, I'd pay careful attention to your ITfThreadMgrEventSink::OnSetFocus implementation (and, obviously, you need to implement ITfThreadMgrEventSink in your text service and connect it via AdviseSink if you haven't already.)
After more research, I've figured out what’s happening:
When you set focus back to Word, TSF gets the current thread’s active keyboard layout (actually a locale ID).
It then compares that keyboard layout with the language ID of the currently active text service.
If they’re different, TSF then activates the text service for the active keyboard layout, and deactivates any previously active text service.
I believe this behavior is different on Vista/Windows 7.
The fix would be to use LoadKeyboardLayout/ActivateKeyboardLayout to set the process keyboard layout in your ITfTextInputProcessor::Activate implementation. Apparently some apps also need you to call ITfInputProcessorProfiles::ChangeCurrentLanguage() as well.

How does "Cinch App" do it?

If you aren't familiar with Cinch, its an application on Mac App Store that allows you to resize ANY window to half/full screen size if you drag the window to the edge of the screen. Exactly like the functionality in windows 7.
Now my question is, how is it done? I have looked all over cocoa apis looking for notifications/delegate methods for whenever a window is being dragged (ALL windows, not just windows owned by the app from which code is running from) but can't find it. Looked in Core Graphics API...Quartz Display Services....but can't find it.
Any help will be greatly appreciated as I have been looking for the past week....Thanks!
Edit: Resize the window is easy since it can be done through applescript bridge..
Are you developer behind i-Snap or some other Mac App Store clone of Cinch?
I'm the developer behind Cinch, and while I try to maintain an "abundance mentality" which basically says "There's enough out there for everyone", I've been upset by the Mac App Store lowering the barrier for entry to this market which has produced a number of half-backed competitors.
I would be thrilled to see some real innovation around the work I have done, and not just clones looking to make a quick buck.
Anyway, you want to look at the Accessibility APIs. It's a Carbon C API. This is probably your best reference: http://developer.apple.com/library/mac/#samplecode/UIElementInspector/Introduction/Intro.html%23//apple_ref/doc/uid/DTS10000728
I've not used the Cinch app, but if I were to do this I'd expect to be using cocoa events. (Also see here) Specifically the mouse handling events, combined with where the mouse is currently on-screen. They probably set a variable when a window is grabbed and then track the mouse pointer until it hits an edge or until they release the mouse button.
Events are very powerful and provide very low level access to what is happening, but can also be very complex. Good luck!
I'm not sure. Maybe the developers combine apple script and carbon events. You can create carbon events to know when the mouse has been clicked or dragged

Windows Phone 7 WebBrowser control swallows manipulation events?

If I place a WebBrowser control on any page, the page no longer responds to manipulation events under the WebBrowser. Other areas of the page work fine.
It's easily confirmed by overriding OnManipulationCompleted in a page, then placing a WebBrowser control on the page. Try swiping over the WebBrowser, and OnManipulationCompleted is never called.
I can't set the WebBrowser to IsHitTestVisible=false because I need to be able to click on links. But I want the page to respond to left/right swipes.
Anyone got any bright ideas? Or know if this is a bug in the current release?
I'd like to extend what Skeet already written.
The point is, that the MS WP7 dev team has published "guidelines", where they highly discourage putting (on the same page) multiple layout controls that accept and react to the same set of gestures. For example, you shouldn't try to embed a Pivot inside a Pano, because the horizontal-swipe will clash and it will be hard do distinguish which of them should execute its actions. The same case is with the browser: it responds to all swipes and pans.. so should not be put in almost any scrolling control!!
Now, having said that, I want to tell you it is possible to overcame it - although it may turn not easy, depending on your actual case.
The most trivial thing to do, if you want to still be notified about the gestures is to use GestureService/GestureListener from the Silverlight Toolkit library. Even when the WebBrowser extinguishes the raw manipulations events, the GestureListener will still be able to notify you - because it apparently listens on some "other layer", I don't exactly want to get in to it now. Just fetch the library, add-reference it, do something like:
GestureService.GetListener( targetcontrol ).Flick( myBrowserFlickHandler );
and it's done - you get the notification whenever someone flicks on the control, with completely no regard of the manipulation events being e.handled=true or not. Small disclaimer here: I don't remember if on 7.0 it works, because the WebBrowser is build a bit differenlty there. On 7.1 and 7.5 it should work.
However, if you apply that on a WebBrowser - you will get the notif - but the webbrowser will get it too. That means, that 2 controls will react, and it turn to be visually quite rejecting if you start some storyboards from within the handler..
On 7.1 and almost-current 7.5, it is possible to play hard with the WebBrowser and to completely control which manipulation-event it will see. Thus, by filtering the mani-events for the WB, and by using GestureListener to see the events yourself, you can both block the WB from doing anything, and at the same time you can respond with your own action instead. I've written about that extensively in a response to similar problem, see WP7 Pivot control and a WebBrowser control for details. It is not a quick/easy/funny thing to do though.
EDIT: and MOST importantly, it is NOT guaranteed to work in the future. Throughout the 7.1 and 7.5 SDK/OS/API versions, inside the WebBrowser control some major internal undergoing changes are visible, and I would not be surprised, if it would dramatically change in the next few releases. Don't play with the things I've wrote there about if you do not want to have to revisit the subject again in the next 1-2 years.
This is a consequence of the way we implemented WebBrowser. The touch events are handed off directly to the browser engine. Once that happens Silverlight is basically out of the picture. Unfortunately I can't think of any workarounds that might give you what you want. -Skeets, MS dev
If you really want it:
<Grid>
<phone:WebBrowser Source="http://www.microsoft.com" />
<Rectangle Fill="Transparent" ManipulationCompleted="HandleManipulationCompleted"/>
</Grid>
But of course it completely locks down interaction with web browser control and there's just no way to echo manipulation events to browser...
I think you have a better way capturing the manipulation events, if it is in WP7.5 Mango since the browser controls are completely different, which I read from this link