|
Viewing 1 to (33 Total) Keyboard Orientation |
Total Posts: 67
Joined: December 08, 2011
|
Is there anyway to change the orientation of the soft keyboard when targetting iOS?
I have used some sample code from someone to rotation the current stage:
Lib.current.rotation = 180;
but it doesn't rotate the keyboard so when you click on a textfield the keyboard is at the top..
Any ideas?
Tags:
Posted on February 02, 2012 at 1:17 AM
|
|
|
Total Posts: 548
Joined: October 07, 2011
|
Re: Keyboard Orientation
Hi,
From memory, I think I disabled the ios rotation and simply implemented it in opengl because on the original hardware it was more efficient to to do ogengl rotations than ios layer rotations. This is probably unnecessary now, and could be the cause of your problems (and makes things more difficult in general). I should move to fully OS rotations and then treat rotations as simple resizes.
You could try:
nme.Lib.current.stage.shouldRotateInterface = function(_) return true;
If you only want landscape, you could try: nme.Lib.current.stage.shouldRotateInterface = function(rot) return rot==Stage.OrientationLandscapeRight || rot==OrientationLandscapeLeft;
If you want to debug, you could put breakpoints in UIStageView.mm in "shouldAutorotateToInterfaceOrientation"
There may also be something in the info.plist that needs setting.
Hugh
Posted on February 02, 2012 at 7:21 PM
|
Total Posts: 67
Joined: December 08, 2011
|
Re: Keyboard Orientation
Interesting.. Yeah I agree that its only rotating the layer, and not via the hardware.
The code you gave me - does that do it hardware wise?
This is very annoying how NME doesnt do it right..
Posted on February 02, 2012 at 8:53 PM
|
Total Posts: 2147
Joined: August 25, 2011
|
Re: Keyboard Orientation
Hugh,
I'd love to hear more about how I can tap into OpenGL rotation of the stage.
On webOS, applications are expected to handle their own rotation this way. I imagine that this might also be necessary to rotate smoothly on Android, because rotating the Java context (just guessing) might have negative consequences on the GL view?
Posted on February 06, 2012 at 10:24 PM
|
Total Posts: 67
Joined: December 08, 2011
|
Re: Keyboard Orientation
Help!
My app got rejected again, since I changed it to Portrait mode, it failed due to not supporting upside down layout, even though I didn't select it in the options in XCode.
We *really* need to sort out the OS-Level rotation! This is a huge problem.
Posted on February 09, 2012 at 5:47 PM
|
Total Posts: 548
Joined: October 07, 2011
|
Re: Keyboard Orientation
I will have a look when I get a spare minute.
The issue is toautomatically support 180 degree rotations with the keyboard, right?
Hugh
Posted on February 10, 2012 at 9:03 AM
|
Total Posts: 151
Joined: January 21, 2012
|
Re: Keyboard Orientation
+1 for better orientation support
It sounds like this is a showstopper bug for apps on iOS. Also, the Stage.getOrientation() doesn't seem to work on Android.
Posted on February 10, 2012 at 12:54 PM
|
Total Posts: 67
Joined: December 08, 2011
|
Re: Keyboard Orientation
Yes it is. Thank you for any help you can provide.
Posted on February 10, 2012 at 1:09 PM
|
Total Posts: 2147
Joined: August 25, 2011
|
Re: Keyboard Orientation
I've been working with this for a while.
It was simple to set auto-rotation for iOS:
Stage.shouldRotateInterface = function (orientation:Int):Bool { return true; }
However, I could not get it to accept the initial orientation. I tried various combinations of Objective-C code, using bits like "[[UIApplication sharedApplication] statusBarOrientation];" and "[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];", but I still could not get it to catch at startup.
Posted on February 10, 2012 at 7:00 PM
|
Total Posts: 151
Joined: January 21, 2012
|
Re: Keyboard Orientation
I've noticed that there are no selections for "Supported Device Orientations" in the Xcode project target for either iPhone/iPod or iPad. Could this have something to do with it?
Have you looked at the default XCode template for "OpenGL Game" in Xcode 4.2.1? That seems to support orientation changes. Perhaps that will shed some light on this?
Posted on February 10, 2012 at 7:24 PM
|
Total Posts: 151
Joined: January 21, 2012
|
Re: Keyboard Orientation
I've never been able to get the OS level rotation working via haXe. I've noticed that ApplicationMain.hx which is generated from my nmml file says this:
nme.display.Stage.setFixedOrientation(nme.display.Stage.OrientationLandscapeLeft);
Question: How do I specify in the nmml file that I want to support more than one orientation?
I've gone in and edited the UIStageView.mm file, which allowed me to set up OS level orientation change between LandscapeLeft and LandscapeRight:
- (BOOL)shouldAutorotateToInterfaceOrientation : (UIInterfaceOrientation)interfaceOrientation { //if (gFixedOrientation>=0) // return interfaceOrientation==gFixedOrientation; Event evt(etShouldRotate); evt.value = interfaceOrientation; sgMainView->mStage->OnEvent(evt); return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown && interfaceOrientation != UIInterfaceOrientationPortrait); //return evt.result == 2; }
Obviously, that's just a hack, but it works great for my purposes, so far at least. It doesn't detect proper orientation at startup, like you said, but it does rotate immediately after startup. Perhaps this article will help figure that one out?http://jeffreysambells.com/posts/2011/09/22/how-to-determine-ios-de...
Posted on February 10, 2012 at 7:54 PM
|
Total Posts: 2147
Joined: August 25, 2011
|
Re: Keyboard Orientation
For iOS, use the code I shared above:
Stage.shouldRotateInterface = function (orientation:Int):Bool { return true; }
You can make your own function that returns true or false, depending on the desired orientation.
Just trying to get it to use an allowed orientation at startup... 
Posted on February 10, 2012 at 8:04 PM
|
Total Posts: 151
Joined: January 21, 2012
|
Re: Keyboard Orientation
Ah! I finally got it working with the stock 3.2 beta binaries:
The key was:
Stage.setFixedOrientation( -1);
Once I did that, the orientation was un-fixed. Then, I followed your instructions:
Stage.shouldRotateInterface = function (orientation:Int):Bool { return (orientation == Stage.OrientationLandscapeLeft || orientation == Stage.OrientationLandscapeRight); }
But yes, it still doesn't startup right.
Is this the right way to do it?
Posted on February 10, 2012 at 11:20 PM
|
Total Posts: 2147
Joined: August 25, 2011
|
Re: Keyboard Orientation
Yes, now we just need to solve the issue of using the correct orientation when the app first launches
Posted on February 10, 2012 at 11:24 PM
|
Total Posts: 2147
Joined: August 25, 2011
|
Re: Keyboard Orientation
You should also be able to use "shouldRotateInterface" (without setting a fixed rotation of -1) if you remove the "orientation" attribute from your NMML 
Posted on February 10, 2012 at 11:27 PM
|
Total Posts: 151
Joined: January 21, 2012
|
Re: Keyboard Orientation
You should also be able to use "shouldRotateInterface" (without setting a fixed rotation of -1) if you remove the "orientation" attribute from your NMML
That was the first thing I tried, but it didn't work for me. Anyway, I wouldn't want it to start in portrait, so keeping it "landscape" works for now.
Posted on February 11, 2012 at 12:57 AM
|
Total Posts: 151
Joined: January 21, 2012
|
Re: Keyboard Orientation
I just found this post in which the cocos2d devs were discussing the same issue:http://www.cocos2d-iphone.org/forum/topic/6413...
I've tried to add a fix for startup, with some success, but I confess I only know enough to be dangerous. In applicationDidFinishLaunching, I added this:
CGAffineTransform transform; switch ([[UIDevice currentDevice] orientation]) { case UIDeviceOrientationPortrait: NSLog(@"Portrait"); transform = CGAffineTransformMakeRotation(0); break; case UIDeviceOrientationPortraitUpsideDown: NSLog(@"UpsideDown"); transform = CGAffineTransformMakeRotation(M_PI); break; case UIDeviceOrientationLandscapeLeft: NSLog(@"LandscapeLeft"); transform = CGAffineTransformMakeRotation(M_PI * 0.5); break; case UIDeviceOrientationLandscapeRight: NSLog(@"LandscapeRight"); transform = CGAffineTransformMakeRotation(0 - M_PI * 0.5); break; default: switch ([UIApplication sharedApplication].statusBarOrientation) { case UIInterfaceOrientationPortrait: NSLog(@"Status - Portrait"); transform = CGAffineTransformMakeRotation(0); break; case UIInterfaceOrientationPortraitUpsideDown: NSLog(@"Status - UpsideDown"); transform = CGAffineTransformMakeRotation(M_PI); break; case UIInterfaceOrientationLandscapeLeft: NSLog(@"Status - LandscapeLeft"); transform = CGAffineTransformMakeRotation(M_PI * 0.5); break; case UIInterfaceOrientationLandscapeRight: NSLog(@"Status - LandscapeRight"); transform = CGAffineTransformMakeRotation(0 - M_PI * 0.5); break; } } transform = CGAffineTransformTranslate(transform, 0, 0); [c.view setTransform:transform];
It *sort of* works.. however in Landscape Left mode, it starts up correctly, but then I see the view mask rotate animation, as thought the view were rotated but I forgot to rotate the mask as well? I don't know.. I think I'm rotating the wrong view. But, if I try to rotate the window, bad things happen - as in the game is always upside down in any orientation. I haven't tested portrait, but I imagine the same thing happens.
Also, I've set up a default for the first switch in case the device is laying flat. Unfortunately the status bar orientation always registers as LandscapeLeft. Not sure why.
Anyway, I thought I'd post this hoping it might help you get unstuck. I'm giving up on it for now, since I can't seem to get it exactly right.
Posted on February 11, 2012 at 3:15 AM
|
Total Posts: 67
Joined: December 08, 2011
|
Re: Keyboard Orientation
Can any help tell me me how I should be doing this?
Someone suggested in the EnterFrame event calling a CheckOrientation function to the rotate etc? Or should I be listening to a rotation event ? Or should it be auto handled?
Any ideas?
Posted on February 11, 2012 at 2:40 PM
|
Total Posts: 151
Joined: January 21, 2012
|
Re: Keyboard Orientation
Have you tried something like this?
Stage.setFixedOrientation( -1); Stage.shouldRotateInterface = function (orientation:Int):Bool { return (orientation == Stage.OrientationPortrait || orientation == Stage.OrientationPortraitUpsideDown); }
Posted on February 11, 2012 at 4:11 PM
|
Total Posts: 67
Joined: December 08, 2011
|
Re: Keyboard Orientation
Where does this code go? In New function or a rotation event change? I'm really unsure how it's suppose to handle it. Or do we just run it once (in new function) and it is auto handled?
Posted on February 11, 2012 at 7:16 PM
|