git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
commit75fac64ca0a38c76d3aac14adcd3c1cfb2168bb2 authorMark <mark.eibes@gmail.com> dateThu 19 Feb 2026, 14:26 (7 months ago) parentdc50332
4 files changed+32−1
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+19 example-macos/src/Demo/Chat.purs+8 src/Yoga/React/Native/MacOS/Button.js+4−1 src/Yoga/React/Native/MacOS/Button.purs+1
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+19
@@ -52,6 +52,7 @@
5252@property (nonatomic, assign) BOOL destructive;
5353@property (nonatomic, assign) BOOL primary;
5454@property (nonatomic, assign) BOOL buttonEnabled;
55+@property (nonatomic, copy) RCTDirectEventBlock onEmojiPick;
5556@end
5657
5758@implementation RCTNativeButtonView
@@ -66,10 +67,27 @@
6667 return self;
6768}
6869
70+- (BOOL)acceptsFirstResponder { return _onEmojiPick != nil; }
71+
6972- (void)handlePress {
73+ if (_onEmojiPick) {
74+ [self.window makeFirstResponder:self];
75+ [NSApp orderFrontCharacterPalette:nil];
76+ return;
77+ }
7078 if (_onPressButton) _onPressButton(@{});
7179}
7280
81+- (void)insertText:(id)string {
82+ if (_onEmojiPick && [string isKindOfClass:[NSString class]]) {
83+ _onEmojiPick(@{@"emoji": string});
84+ }
85+}
86+
87+- (void)doCommandBySelector:(SEL)selector {
88+ // Required by NSTextInputClient protocol — ignore commands
89+}
90+
7391- (void)mouseEntered:(NSEvent *)event {
7492 if (_borderlessHover) {
7593 ((RCTBorderlessButtonCell *)_button.cell).hovered = YES;
@@ -170,6 +188,7 @@ RCT_EXPORT_VIEW_PROPERTY(destructive, BOOL)
170188RCT_EXPORT_VIEW_PROPERTY(primary, BOOL)
171189RCT_EXPORT_VIEW_PROPERTY(buttonEnabled, BOOL)
172190RCT_EXPORT_VIEW_PROPERTY(onPressButton, RCTDirectEventBlock)
191+RCT_EXPORT_VIEW_PROPERTY(onEmojiPick, RCTDirectEventBlock)
173192@end
174193
175194// ============================================================
example-macos/src/Demo/Chat.purs+8
@@ -316,6 +316,14 @@ chatDemo = component "ChatDemo" \dp -> React.do
316316 }
317317 )
318318 reactionEmoji
319+ <>
320+ [ nativeButton
321+ { title: "+"
322+ , bezelStyle: T.borderless
323+ , onEmojiPick: reactToMessage idx
324+ , style: Style.style { height: 28.0, width: 28.0 }
325+ }
326+ ]
319327 )
320328 ]
321329
src/Yoga/React/Native/MacOS/Button.js+4−1
@@ -2,10 +2,13 @@ import React from "react";
22import { requireNativeComponent } from "react-native";
33const NativeButton = requireNativeComponent("NativeButton");
44export const buttonImpl = React.forwardRef((props, ref) => {
5− const { onPress, ...rest } = props;
5+ const { onPress, onEmojiPick, ...rest } = props;
66 const nativeProps = { ...rest };
77 if (typeof onPress === "function") {
88 nativeProps.onPressButton = () => onPress();
99 }
10+ if (typeof onEmojiPick === "function") {
11+ nativeProps.onEmojiPick = (e) => onEmojiPick(e.nativeEvent.emoji)();
12+ }
1013 return React.createElement(NativeButton, { ...nativeProps, ref });
1114});
src/Yoga/React/Native/MacOS/Button.purs+1
@@ -20,4 +20,5 @@ type NativeButtonAttributes = BaseAttributes
2020 , primary :: Boolean
2121 , buttonEnabled :: Boolean
2222 , onPress :: Effect Unit
23+ , onEmojiPick :: String -> Effect Unit
2324 )