Getting Touch input from UIView overlay

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
SFAOK
Kobold
Posts: 32
Joined: Thu May 20, 2004 9:22 pm

Getting Touch input from UIView overlay

Post by SFAOK »

I have Ogre ( 1.8 ) running on the iPad, with a full screen UIView overlayed with a bunch of buttons and sliders on it.

The problem is I can't get it to recognise touches to the UIViewController, only the Ogre view reacts (i.e. move camera). I've read practically every thread on this forum many times over, but so far no luck.

Based on http://www.ogre3d.org/forums/viewtopic.php?f=21&t=64123, this is what I'm currently doing:

(template project, AppDelegate.h, go() function).

Code: Select all

    //Get Ogre window
    UIWindow *mUIWindow = nil;
    Ogre::RenderWindow *mWindow = Ogre::Root::getSingleton().getAutoCreatedWindow();
    mWindow->getCustomAttribute("WINDOW", &mUIWindow);

    //Create custom view controller (overlay)
    myViewController = [[MainViewController alloc] initWithNibName:@"TestView" bundle:nil];

    //Get Ogre UIView
    UIView* mUIView = mUIWindow.rootViewController.view;

    //Add overlay as subview
    [mUIView setFrame:myViewController.view.frame];
    [mUIView addSubview:myViewController.view];
  
    [mUIWindow bringSubviewToFront:myViewController.view];
    [mUIWindow makeKeyAndVisible];
The above code creates and display the cocoa-touch overlay ok, but there's no touch input registered (i.e. buttons don't react, touchesBegan is never triggered).

The only line of code ommited is

Code: Select all

window.rootViewController = myViewController;
the reason being when I add this line, I get a black screen when running and the error message "Application windows are expected to have a root view controller at the end of application launch". Maybe I'm not initialising my custom ViewController correctly or something?

I'd be very grateful for any help!
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Getting Touch input from UIView overlay

Post by masterfalcon »

Are you using both the OIS based and UIView based input? Only one can be active.
SFAOK
Kobold
Posts: 32
Joined: Thu May 20, 2004 9:22 pm

Re: Getting Touch input from UIView overlay

Post by SFAOK »

Ah - I haven't really modified the template code, so yes. I'll try disabling OIS, thanks.
SFAOK
Kobold
Posts: 32
Joined: Thu May 20, 2004 9:22 pm

Re: Getting Touch input from UIView overlay

Post by SFAOK »

Ok removing all OIS code from the project worked perfectly, thanks.

At the moment I can press buttons, sample touch input and print out to the console from inside the custom View Controller (NSLog).

What is the best way of passing data (such as which button is pressed) from the view controller to my actual C++ Ogre application?
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Getting Touch input from UIView overlay

Post by masterfalcon »

You'll probably need a reference in your view controller to whatever class is going to do the processing.
User avatar
hallucinogen
Gnoblar
Posts: 7
Joined: Fri Jun 01, 2012 7:44 am

Re: Getting Touch input from UIView overlay

Post by hallucinogen »

OIS code made some problem but solved it.

Edit:
SFAOK wrote:Ok removing all OIS code from the project worked perfectly, thanks.

At the moment I can press buttons, sample touch input and print out to the console from inside the custom View Controller (NSLog).

What is the best way of passing data (such as which button is pressed) from the view controller to my actual C++ Ogre application?
Like he said... need to read more carful.