Detecting multitouch on a UIView overlaid on the OF view?

Hi folks,

I have a full screen OF view running fine on my iPad/iPod. Multitouch is running beautifully… :smiley:

Didn’t find a way to get the multitouch on the UIView overlay, so I faked it as described above. Works fine, if not so elegant in the architecture…

Would still be interested in knowing the answer though, in case anyone knows… :slight_smile:

Hi Gwydion,

I’d be interested in a solution to this as well. It would seem that the OFx app is not in the UIResponder chain. As, when I place a view controller (loaded from a nib) as a subview of my main window (and bring it to the front), the unhandled touch events do not flow to the OFx application.

I know the OFx gui example app clearly states that this will happen. I’m just wondering if there is a way to get this to work.

Gwydion, what was your solution, if you don’t mind adding some detail here.

Thanks,
Kyle

Hi Kyle, my solution was to not use UIView at all, unfortunately. Instead, I drew my overlay view using standard OF rectangles and circles, and draw it last, so that it gives the appearance that it is in top of the main OF view. It’s not a separate view or subview, it just looks like one :slight_smile: . Doing it this way allowed me to keep using multitouch on both views at the same time, but with the disadvantage of not being able to use the Cocoa Touch UI elements’ look and feel, i.e. I had to draw my own style of buttons.

Hope that helps explain a little.

One thing you can do - if say your gui is just a nav bar or something and you want the rest of the space to be OF with touch is to make the gui view the size of just the nav element in project builder and then position it in the right place in viewDidLoad . All touches that aren’t in the nav bar area will pass through to OF.

Hi Gwydion and Theo,

Thank you for your responses.

For the time being, I’m adding my UIView via addSubview on ofxiPhoneGetGLView(). This was suggested by prisonerjohn, in this post:
http://forum.openframeworks.cc/t/capture-touch-events-in-multiple-views/2544/4

  
myVC = [[MyVC alloc] initWithNibName:@"myVC" bundle:nil];  
[ofxiPhoneGetGLView() addSubview: myVCr.view];  

Along with this, I’m setting my NIB properties to have a transparent background and allow multitouch. Any touches not hitting a handled by a UI element layed out in the NIB is passed to OF.

Theo, how are you adding your UIView elements to the OF view? Are you also using the ofxiPhoneGetGLView and then adding view addSubview? If you’re doing something else, it sounds like you are proposing a different method.

Thanks and best regards,
Kyle

Hi, I have the same need but the ofxiPhoneGetGLView() did not work for me…

This code is working without touch event on my of view:

  
UIWindow* window = [ [ UIApplication sharedApplication ] keyWindow ];  
[ window addSubview: self.viewController.view ];  
  

I have tried this:

  
UIWindow* window =[ ofxiPhoneGetGLView() addSubview: self.viewController.view];    
  

but I have an error with ofxiPhoneGetGLView…

Try to explicitly include “ofxiPhoneExtras.h”.