Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
jmethodID mat_jViewNotifyRepaint = 0;
jmethodID mat_jViewNotifyKey = 0;
jmethodID mat_jViewNotifyMouse = 0;
jmethodID mat_jViewNotifyMenu = 0;
jmethodID mat_jViewNotifyInputMethod = 0;
jmethodID mat_jViewNotifyView = 0;

Expand Down Expand Up @@ -671,6 +672,7 @@ - (void)dealloc {
mat_jViewNotifyResize = (*env)->GetMethodID(env, mat_jViewBaseClass, "notifyResize", "(II)V");
mat_jViewNotifyRepaint = (*env)->GetMethodID(env, mat_jViewBaseClass, "notifyRepaint", "(IIII)V");
mat_jViewNotifyMouse = (*env)->GetMethodID(env, mat_jViewBaseClass, "notifyMouse", "(IIIIIIIZZ)V");
mat_jViewNotifyMenu = (*env)->GetMethodID(env, mat_jViewBaseClass, "notifyMenu", "(IIIIZ)V");
mat_jViewNotifyInputMethod = (*env)->GetMethodID(env, mat_jViewBaseClass, "notifyInputMethod", "(Ljava/lang/String;[I[I[BIII)V");
mat_jViewNotifyView = (*env)->GetMethodID(env, mat_jViewBaseClass, "notifyView", "(I)V");
GLASS_CHECK_EXCEPTION(env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,19 @@ - (void)handleRotateGesture:(UIRotationGestureRecognizer*)sender {
}


- (void)handleLongPressGesture:(UILongPressGestureRecognizer*)sender {
if (sender.state == UIGestureRecognizerStateBegan) {
// Simulate right-click
CGPoint viewPoint = [sender locationInView:self.uiView.superview];
[self sendJavaMouseEvent:viewPoint type:com_sun_glass_events_MouseEvent_ENTER button:com_sun_glass_events_MouseEvent_BUTTON_NONE];
[self sendJavaMouseEvent:viewPoint type:com_sun_glass_events_MouseEvent_DOWN button:com_sun_glass_events_MouseEvent_BUTTON_RIGHT];
} else if (sender.state == UIGestureRecognizerStateEnded) {
// Prevent touch ended event
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no release event needed?

Copy link
Collaborator Author

@jperedadnr jperedadnr Jun 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "right-click" event (enter+right down) is simulated when the long press event is detected (UIGestureRecognizerStateBegan , which happens after 0.5 seconds by default). This will trigger the ContextMenu.

However, the user is still pressing for a few more time. After releasing the tap, (UIGestureRecognizerStateEnded), there is no need of adding a release event (exit+right up), as this probably will close the ContextMenu. The user now can select any of the options from the menu, or simply tap elsewhere to close it.

self.mouseTouch = nil;
}
}


- (id)initWithView:(UIScrollView*)view withJview:(jobject)jview
{
self = [super init];
Expand Down Expand Up @@ -422,6 +435,15 @@ - (id)initWithView:(UIScrollView*)view withJview:(jobject)jview
[panGestureRecognizer setCancelsTouchesInView:NO];
[panGestureRecognizer setDelaysTouchesBegan:NO];
[panGestureRecognizer setDelaysTouchesEnded:NO];
//LongPress
UILongPressGestureRecognizer *longPressGesture =
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)];
[longPressGesture setCancelsTouchesInView:NO];
[longPressGesture setDelaysTouchesEnded:NO];
[longPressGesture setDelaysTouchesBegan:NO];
[self.uiView addGestureRecognizer:longPressGesture];
[longPressGesture setDelegate:ggDelegate];
[longPressGesture release];
}
return self;
}
Expand Down Expand Up @@ -551,6 +573,13 @@ - (void)sendJavaMouseEvent:(CGPoint)viewPoint type:(int)type button:(int)button
(jint)viewPoint.x, (jint)viewPoint.y, (jint)viewPoint.x, (jint)viewPoint.y,
modifiers, isPopupTrigger, isSynthesized);
GLASS_CHECK_EXCEPTION(env);

if (isPopupTrigger) {
jboolean isKeyboardTrigger = JNI_FALSE;
(*env)->CallVoidMethod(env, self.jView, mat_jViewNotifyMenu,
(jint)viewPoint.x, (jint)viewPoint.y, (jint)viewPoint.x, (jint)viewPoint.y, isKeyboardTrigger);
GLASS_CHECK_EXCEPTION(env);
}
}


Expand Down
1 change: 1 addition & 0 deletions modules/javafx.graphics/src/main/native-glass/ios/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern jmethodID mat_jViewNotifyResize;
extern jmethodID mat_jViewNotifyRepaint;
extern jmethodID mat_jViewNotifyKey;
extern jmethodID mat_jViewNotifyMouse;
extern jmethodID mat_jViewNotifyMenu;
extern jmethodID mat_jViewNotifyInputMethod;
extern jmethodID mat_jViewNotifyView;

Expand Down