I have a simple input form that consists of a single textbox and an “OK/Cancel” buttons. To save the user some taps, I bring the focus to the text box when the page is shown, so the keyboard pops up. At this point, I want the “Back” button to behave the same as cancel and navigate back if pressed, but what the thing actually does, it just removes the focus from the text box without even firing the BackKeyPress event. On the next press it does move back, but this is two clicks instead of one.
So I have two questions
- How to make the back button “go back” even when the keyboard is visible?
- Am I trying to do something bad from the standpoint of the WP7 interaction design?
What you can do is handle the textbox’s KeyUp method. When a key is pressed, check if it’s the hardware back key. In my test, the hardware back key has a
PlatformKeyCodeof 27. I’m not sure if this changes between hardware devices. However, assuming it doesn’t, you could do the following:As to whether this is a good idea, I’m not sure. The primary function of the back key, in regards to the on-screen keyboard, is to close the keyboard. This is what users will mostly experience throughout various applications, so that’s what they might expect from yours. However, since you’re SIP is automatically displayed, I guess you could argue it’s almost part of the layout itself. I couldn’t see anything in the UI Guidelines about it, but you should have a read in case I’ve missed something.