| Flutter macOS Embedder |

Public Member Functions | List of all members
flutter::FlutterTextPlatformNode Class Reference

The ax platform node for a text field. More...

`#include <FlutterTextInputSemanticsObject.h>`

Inheritance diagram for flutter::FlutterTextPlatformNode:

## Public Member Functions
| FlutterTextPlatformNode (FlutterPlatformNodeDelegate *delegate, __weak FlutterViewController *view_controller)
| Creates a FlutterTextPlatformNode that uses a FlutterTextField as its NativeViewAccessible. More...
| ~FlutterTextPlatformNode () override
NSRect | GetFrame ()
| Gets the frame of this platform node relative to the view of FlutterViewController. This is used by the FlutterTextField to get its frame rect because the FlutterTextField is a subview of the FlutterViewController.view. More...
gfx::NativeViewAccessible | GetNativeViewAccessible () override

## Detailed Description

The ax platform node for a text field.

Definition at line 22 of file FlutterTextInputSemanticsObject.h.

## Constructor & Destructor Documentation

## ◆ FlutterTextPlatformNode()

flutter::FlutterTextPlatformNode::FlutterTextPlatformNode | ( | FlutterPlatformNodeDelegate * | delegate,
|  | __weak FlutterViewController * | view_controller
| ) |  |
| explicit

Creates a FlutterTextPlatformNode that uses a FlutterTextField as its NativeViewAccessible.

Parameters

  [in] | delegate | The delegate that provides accessibility data.
  [in] | view_controller | The view_controller that is used for querying the information about FlutterView and FlutterTextInputPlugin.

Definition at line 161 of file FlutterTextInputSemanticsObject.mm.

162 {
163 Init(delegate);
164 view_controller_ = view_controller;
165 appkit_text_field_ =
166 [[FlutterTextField alloc] initWithPlatformNode:this
167 fieldEditor:view_controller.textInputPlugin];
168 appkit_text_field_.bezeled = NO;
169 appkit_text_field_.drawsBackground = NO;
170 appkit_text_field_.bordered = NO;
171 appkit_text_field_.focusRingType = NSFocusRingTypeNone;
172 }

## ◆ ~FlutterTextPlatformNode()

flutter::FlutterTextPlatformNode::~FlutterTextPlatformNode | ( |  | ) |
| override

Definition at line 174 of file FlutterTextInputSemanticsObject.mm.

174 {
175 [appkit_text_field_ setPlatformNode:nil];
176 EnsureDetachedFromView();
177 }

## Member Function Documentation

## ◆ GetFrame()

NSRect flutter::FlutterTextPlatformNode::GetFrame | ( |  | ) |

Gets the frame of this platform node relative to the view of FlutterViewController. This is used by the FlutterTextField to get its frame rect because the FlutterTextField is a subview of the FlutterViewController.view.

Definition at line 186 of file FlutterTextInputSemanticsObject.mm.

186 {
187 if (!view_controller_.viewLoaded) {
188 return NSZeroRect;
189 }
190 FlutterPlatformNodeDelegate* delegate = static_cast<FlutterPlatformNodeDelegate*>(GetDelegate());
191 bool offscreen;
192 auto bridge_ptr = delegate->GetOwnerBridge().lock();
193 if (!bridge_ptr) {
194 return NSZeroRect;
195 }
196 gfx::RectF bounds = bridge_ptr->RelativeToGlobalBounds(delegate->GetAXNode(), offscreen, true);
197
198 // Converts to NSRect to use NSView rect conversion.
199 NSRect ns_local_bounds = NSMakeRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
200 // The macOS XY coordinates start at bottom-left and increase toward top-right,
201 // which is different from the Flutter's XY coordinates that start at top-left
202 // increasing to bottom-right. Flip the y coordinate to convert from Flutter
203 // coordinates to macOS coordinates.
204 ns_local_bounds.origin.y = -ns_local_bounds.origin.y - ns_local_bounds.size.height;
205 NSRect ns_view_bounds = [view_controller_.flutterView convertRectFromBacking:ns_local_bounds];
206 return [view_controller_.flutterView convertRect:ns_view_bounds toView:nil];
207 }

References flutter::FlutterPlatformNodeDelegate::GetAXNode(), and flutter::FlutterPlatformNodeDelegate::GetOwnerBridge().

## ◆ GetNativeViewAccessible()

gfx::NativeViewAccessible flutter::FlutterTextPlatformNode::GetNativeViewAccessible | ( |  | ) |
| override

Definition at line 179 of file FlutterTextInputSemanticsObject.mm.

179 {
180 if (EnsureAttachedToView()) {
181 return appkit_text_field_;
182 }
183 return nil;
184 }

Referenced by flutter::testing::TEST().

The documentation for this class was generated from the following files:

- shell/platform/darwin/macos/framework/Source/FlutterTextInputSemanticsObject.h
- shell/platform/darwin/macos/framework/Source/FlutterTextInputSemanticsObject.mm

FlutterTextField
Definition: FlutterTextInputSemanticsObject.h:81