Skip to content

Commit 6e88486

Browse files
committed
edits
1 parent a38a146 commit 6e88486

3 files changed

Lines changed: 104 additions & 124 deletions

File tree

docsite/api/intro.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,4 @@ slug: /
77

88
Welcome to the React Native macOS API reference documentation. This section covers macOS-specific props and events that extend the standard React Native components.
99

10-
## View Component Extensions
11-
12-
React Native macOS extends the standard View component with additional props and events designed specifically for macOS:
13-
14-
- **[View Props](./view-props.md)** - macOS-specific properties for customizing view behavior
15-
- **[View Events](./view-events.md)** - macOS-specific events for handling user interactions
16-
17-
These extensions allow you to build truly native macOS experiences while leveraging the React Native framework.
10+
Most of the additional functionality out of React Native macOS directly is in the form of additional props and callback events implemented on `<View>`, to provide macOS and desktop specific behavior

docsite/api/view-events.md

Lines changed: 96 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,30 @@
11
---
2-
sidebar_label: 'View Events (macOS)'
2+
sidebar_label: 'Events'
33
sidebar_position: 2
44
---
55

6-
# View Events (macOS)
6+
# Events
77

88
React Native macOS extends the standard React Native View component with additional events that are specific to macOS. These events allow you to respond to macOS-specific user interactions such as keyboard input, mouse movements, drag and drop operations, and more.
99

10-
## Events
10+
## Focus
1111

12-
### `onBlur`
13-
14-
Fired when the view loses focus.
15-
16-
**Event Data:** Standard focus event
17-
18-
This event is useful for implementing custom focus management and validation logic when a view loses keyboard focus.
19-
20-
---
21-
22-
### `onDoubleClick`
23-
24-
Fired when the user double-clicks on the view.
25-
26-
**Event Data:** Mouse event with the following properties:
27-
- `clientX`: Horizontal position in the target view
28-
- `clientY`: Vertical position in the target view
29-
- `screenX`: Horizontal position in the window
30-
- `screenY`: Vertical position in the window
31-
- `altKey`: Whether Alt/Option key is pressed
32-
- `ctrlKey`: Whether Control key is pressed
33-
- `shiftKey`: Whether Shift key is pressed
34-
- `metaKey`: Whether Command key is pressed
35-
36-
Example:
37-
```javascript
38-
<View onDoubleClick={(event) => {
39-
console.log('Double clicked at', event.nativeEvent.clientX, event.nativeEvent.clientY);
40-
}}>
41-
<Text>Double click me</Text>
42-
</View>
43-
```
44-
45-
---
46-
47-
### `onDragEnter`
48-
49-
Fired when a drag operation enters the view's bounds.
50-
51-
**Event Data:** Drag event with mouse position and data transfer information
52-
53-
This event is fired when the user drags content over the view. Use this to provide visual feedback that the view can accept the dragged content.
54-
55-
---
56-
57-
### `onDragLeave`
58-
59-
Fired when a drag operation leaves the view's bounds.
12+
This event is useful for implementing custom focus management and showing focus-specific UI elements. For these to fire, the prop [focusable](view-props#focusable) must be set.
6013

61-
**Event Data:** Drag event with mouse position and data transfer information
14+
### `onFocus`
6215

63-
This event is fired when the user drags content away from the view. Use this to remove any visual feedback shown during drag enter.
16+
Fired when the view receives focus.
6417

6518
---
6619

67-
### `onDrop`
68-
69-
Fired when the user drops content onto the view.
70-
71-
**Event Data:** Drag event with the following properties:
72-
- Mouse position (`clientX`, `clientY`, `screenX`, `screenY`)
73-
- Modifier keys (`altKey`, `ctrlKey`, `shiftKey`, `metaKey`)
74-
- `dataTransfer`: Object containing:
75-
- `files`: Array of dropped files, each with:
76-
- `name`: File name
77-
- `type`: MIME type
78-
- `uri`: File URI
79-
- `size`: File size (optional)
80-
- `width`: Image width (optional, for images)
81-
- `height`: Image height (optional, for images)
82-
- `items`: Array of data transfer items, each with:
83-
- `kind`: Item kind (e.g., 'file', 'string')
84-
- `type`: MIME type
85-
- `types`: Array of available data types
20+
### `onBlur`
8621

87-
Example:
88-
```javascript
89-
<View
90-
draggedTypes={['public.file-url']}
91-
onDrop={(event) => {
92-
const files = event.nativeEvent.dataTransfer.files;
93-
files.forEach(file => {
94-
console.log('Dropped file:', file.name, file.uri);
95-
});
96-
}}
97-
>
98-
<Text>Drop files here</Text>
99-
</View>
100-
```
22+
Fired when the view loses focus. This is supported for all Views
10123

10224
---
10325

104-
### `onFocus`
105-
106-
Fired when the view receives focus.
107-
108-
**Event Data:** Standard focus event
109-
110-
This event is useful for implementing custom focus management and showing focus-specific UI elements.
11126

112-
---
27+
## Keyboard
11328

11429
### `onKeyDown`
11530

@@ -134,10 +49,10 @@ Example:
13449
```javascript
13550
<View
13651
focusable={true}
137-
keyDownEvents={[
52+
keyDownEvents=[
13853
{ key: 'Enter' },
13954
{ key: 's', metaKey: true }
140-
]}
55+
]
14156
onKeyDown={(event) => {
14257
const { key, metaKey } = event.nativeEvent;
14358
if (key === 'Enter') {
@@ -165,6 +80,8 @@ To receive key events, the view must have `focusable={true}` set, and you should
16580

16681
---
16782

83+
## Mouse
84+
16885
### `onMouseEnter`
16986

17087
Fired when the mouse cursor enters the view's bounds.
@@ -209,6 +126,88 @@ Example:
209126

210127
---
211128

129+
### `onDoubleClick`
130+
131+
Fired when the user double-clicks on the view.
132+
133+
**Event Data:** Mouse event with the following properties:
134+
- `clientX`: Horizontal position in the target view
135+
- `clientY`: Vertical position in the target view
136+
- `screenX`: Horizontal position in the window
137+
- `screenY`: Vertical position in the window
138+
- `altKey`: Whether Alt/Option key is pressed
139+
- `ctrlKey`: Whether Control key is pressed
140+
- `shiftKey`: Whether Shift key is pressed
141+
- `metaKey`: Whether Command key is pressed
142+
143+
Example:
144+
```javascript
145+
<View onDoubleClick={(event) => {
146+
console.log('Double clicked at', event.nativeEvent.clientX, event.nativeEvent.clientY);
147+
}}>
148+
<Text>Double click me</Text>
149+
</View>
150+
```
151+
152+
---
153+
154+
### `onDragEnter`
155+
156+
Fired when a drag operation enters the view's bounds.
157+
158+
**Event Data:** Drag event with mouse position and data transfer information
159+
160+
This event is fired when the user drags content over the view. Use this to provide visual feedback that the view can accept the dragged content.
161+
162+
---
163+
164+
### `onDragLeave`
165+
166+
Fired when a drag operation leaves the view's bounds.
167+
168+
**Event Data:** Drag event with mouse position and data transfer information
169+
170+
This event is fired when the user drags content away from the view. Use this to remove any visual feedback shown during drag enter.
171+
172+
---
173+
174+
### `onDrop`
175+
176+
Fired when the user drops content onto the view.
177+
178+
**Event Data:** Drag event with the following properties:
179+
- Mouse position (`clientX`, `clientY`, `screenX`, `screenY`)
180+
- Modifier keys (`altKey`, `ctrlKey`, `shiftKey`, `metaKey`)
181+
- `dataTransfer`: Object containing:
182+
- `files`: Array of dropped files, each with:
183+
- `name`: File name
184+
- `type`: MIME type
185+
- `uri`: File URI
186+
- `size`: File size (optional)
187+
- `width`: Image width (optional, for images)
188+
- `height`: Image height (optional, for images)
189+
- `items`: Array of data transfer items, each with:
190+
- `kind`: Item kind (e.g., 'file', 'string')
191+
- `type`: MIME type
192+
- `types`: Array of available data types
193+
194+
Example:
195+
```javascript
196+
<View
197+
draggedTypes={['public.file-url']}
198+
onDrop={(event) => {
199+
const files = event.nativeEvent.dataTransfer.files;
200+
files.forEach(file => {
201+
console.log('Dropped file:', file.name, file.uri);
202+
});
203+
}}
204+
>
205+
<Text>Drop files here</Text>
206+
</View>
207+
```
208+
209+
---
210+
212211
## Complete Example
213212

214213
Here's a comprehensive example showing multiple macOS-specific events:
@@ -262,14 +261,7 @@ function MacOSEventsExample() {
262261
);
263262
}
264263

265-
const styles = StyleSheet.create({
266-
container: {
267-
flex: 1,
268-
justifyContent: 'center',
269-
alignItems: 'center',
270-
},
271-
interactiveView: {
272-
width: 300,
264+
273265
height: 200,
274266
backgroundColor: 'white',
275267
borderWidth: 2,
@@ -287,8 +279,3 @@ const styles = StyleSheet.create({
287279

288280
export default MacOSEventsExample;
289281
```
290-
291-
## See Also
292-
293-
- [View Props (macOS)](./view-props.md) - macOS-specific props for View components
294-
- [React Native View Component](https://reactnative.dev/docs/view) - Base View component documentation

docsite/api/view-props.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
sidebar_label: 'View Props (macOS)'
2+
sidebar_label: 'Props'
33
sidebar_position: 1
44
---
55

6-
# View Props (macOS)
6+
# Props
77

8-
React Native macOS extends the standard React Native View component with additional props that are specific to macOS. These props allow you to customize the behavior and appearance of views to take advantage of macOS-specific features.
8+
React Native macOS extends the standard React Native `<View>` component with additional props that are specific to macOS. These props allow you to customize the behavior and appearance of views to take advantage of macOS-specific features.
99

1010
## Props
1111

@@ -29,7 +29,7 @@ Enables the vibrancy effect for the view, allowing it to blend with the content
2929
| ---- | ------- |
3030
| bool | `false` |
3131

32-
When `true`, the view will use macOS vibrancy effects, creating a translucent appearance that adapts to the content behind the window.
32+
When `true`, the view will use macOS vibrancy effects, creating a translucent appearance that adapts to the content behind the window. This makes a difference when content is placed on top of a native [NSVisualEffectView](https://developer.apple.com/documentation/appkit/nsvisualeffectview), such as with the native module [VibrancyView](https://github.com/microsoft/fluentui-react-native/tree/main/packages/experimental/VibrancyView)
3333

3434
---
3535

@@ -41,7 +41,7 @@ Specifies the mouse cursor to display when hovering over the view.
4141
| ------ |
4242
| string |
4343

44-
Sets the cursor style. Common values include `'pointer'`, `'default'`, `'text'`, etc.
44+
Sets the cursor style. This extends the React Native prop to support a larger range of the W3C cursor types supported on web.
4545

4646
---
4747

@@ -53,7 +53,7 @@ Specifies the types of dragged content that the view accepts for drag and drop o
5353
| --------------- |
5454
| array of string |
5555

56-
An array of UTI (Uniform Type Identifier) strings that the view will accept. For example: `['public.file-url', 'public.text']`.
56+
An array of UTI (Uniform Type Identifier) strings that the view will accept. Currently supported: `['fileUrl', 'image', 'string']`.
5757

5858
---
5959

@@ -71,7 +71,7 @@ When `true`, macOS will draw the standard focus ring around the view when it rec
7171

7272
### `focusable`
7373

74-
Determines whether the view can receive keyboard focus.
74+
Determines whether the view can receive keyboard focus. This prop has been extended from React Native Core to support all views.
7575

7676
| Type | Default |
7777
| ---- | ------- |

0 commit comments

Comments
 (0)