Skip to content

Commit 8c07293

Browse files
committed
- add os_tapped
1 parent 35e56d3 commit 8c07293

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

core/pen/include/os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ namespace pen
6060
Str os_get_clipboard_string();
6161
void os_clear_clipboard_string();
6262
void os_enable_paste_popup(bool enable);
63+
bool os_tapped();
6364

6465
// music
6566
struct music_item

core/pen/source/ios/os.mm

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ -(MPRemoteCommandHandlerStatus)like;
9090
bool require_audio_reinit = false;
9191
Str clipboard = "";
9292
bool enable_paste_popup = false;
93+
bool tapped = false;
9394
};
9495
os_context s_context;
9596

@@ -177,8 +178,11 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
177178
pen::os_init_on_screen_keyboard();
178179

179180
// long press gesture for paste menu
180-
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self.view_controller action:@selector(handleLongPress:)];
181-
[self.mtk_view addGestureRecognizer:longPress];
181+
UILongPressGestureRecognizer *long_press = [[UILongPressGestureRecognizer alloc] initWithTarget:self.view_controller action:@selector(handleLongPress:)];
182+
[self.mtk_view addGestureRecognizer:long_press];
183+
184+
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self.view_controller action:@selector(viewWasTapped:)];
185+
[self.mtk_view addGestureRecognizer:tap];
182186

183187
return YES;
184188
}
@@ -289,6 +293,7 @@ - (void)drawInMTKView:(nonnull MTKView*)view
289293
@implementation pen_view_controller
290294
- (void)viewWasTapped:(id)sender
291295
{
296+
s_context.tapped = true;
292297
}
293298

294299
- (void)viewWasDoubleTapped:(id)sender
@@ -928,4 +933,11 @@ void os_enable_paste_popup(bool enable)
928933
{
929934
s_context.enable_paste_popup = enable;
930935
}
936+
937+
bool os_tapped()
938+
{
939+
bool res = s_context.tapped;
940+
s_context.tapped = false; // consume
941+
return res;
942+
}
931943
}

0 commit comments

Comments
 (0)