@@ -375,6 +375,19 @@ - (void)handleRotateGesture:(UIRotationGestureRecognizer*)sender {
375375}
376376
377377
378+ - (void )handleLongPressGesture : (UILongPressGestureRecognizer*)sender {
379+ if (sender.state == UIGestureRecognizerStateBegan) {
380+ // Simulate right-click
381+ CGPoint viewPoint = [sender locationInView: self .uiView.superview];
382+ [self sendJavaMouseEvent: viewPoint type: com_sun_glass_events_MouseEvent_ENTER button: com_sun_glass_events_MouseEvent_BUTTON_NONE];
383+ [self sendJavaMouseEvent: viewPoint type: com_sun_glass_events_MouseEvent_DOWN button: com_sun_glass_events_MouseEvent_BUTTON_RIGHT];
384+ } else if (sender.state == UIGestureRecognizerStateEnded) {
385+ // Prevent touch ended event
386+ self.mouseTouch = nil ;
387+ }
388+ }
389+
390+
378391- (id )initWithView : (UIScrollView*)view withJview : (jobject)jview
379392{
380393 self = [super init ];
@@ -422,6 +435,15 @@ - (id)initWithView:(UIScrollView*)view withJview:(jobject)jview
422435 [panGestureRecognizer setCancelsTouchesInView: NO ];
423436 [panGestureRecognizer setDelaysTouchesBegan: NO ];
424437 [panGestureRecognizer setDelaysTouchesEnded: NO ];
438+ // LongPress
439+ UILongPressGestureRecognizer *longPressGesture =
440+ [[UILongPressGestureRecognizer alloc ] initWithTarget: self action: @selector (handleLongPressGesture: )];
441+ [longPressGesture setCancelsTouchesInView: NO ];
442+ [longPressGesture setDelaysTouchesEnded: NO ];
443+ [longPressGesture setDelaysTouchesBegan: NO ];
444+ [self .uiView addGestureRecognizer: longPressGesture];
445+ [longPressGesture setDelegate: ggDelegate];
446+ [longPressGesture release ];
425447 }
426448 return self;
427449}
@@ -551,6 +573,13 @@ - (void)sendJavaMouseEvent:(CGPoint)viewPoint type:(int)type button:(int)button
551573 (jint)viewPoint.x , (jint)viewPoint.y , (jint)viewPoint.x , (jint)viewPoint.y ,
552574 modifiers, isPopupTrigger, isSynthesized);
553575 GLASS_CHECK_EXCEPTION (env);
576+
577+ if (isPopupTrigger) {
578+ jboolean isKeyboardTrigger = JNI_FALSE;
579+ (*env)->CallVoidMethod (env, self.jView , mat_jViewNotifyMenu,
580+ (jint)viewPoint.x , (jint)viewPoint.y , (jint)viewPoint.x , (jint)viewPoint.y , isKeyboardTrigger);
581+ GLASS_CHECK_EXCEPTION (env);
582+ }
554583}
555584
556585
0 commit comments