Skip to content

Commit

Permalink
Add support for providing the “inputPlaceholder” for the placeholder …
Browse files Browse the repository at this point in the history
…string that will be displayed when the modal input is empty
  • Loading branch information
kasper committed Feb 13, 2022
1 parent b2e2e57 commit 881342f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Release: dd.mm.yyyy

- New: Property `hasShadow` for whether the modal has a shadow.
- New: Property `isInput` for whether the modal behaves as an input modal ([#163](https://github.com/kasper/phoenix/issues/163)).
- New: Property `inputPlaceholder` for the placeholder string that will be displayed when the input is empty ([#163](https://github.com/kasper/phoenix/issues/163)).
- New: Property `textDidChange` callback function to call when the input modal’s text field value changes ([#163](https://github.com/kasper/phoenix/issues/163)).

#### Space
Expand Down
2 changes: 2 additions & 0 deletions Phoenix/PHModalWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@property NSImage *icon;
@property (copy) NSString *text;
@property BOOL isInput;
@property (copy) NSString *inputPlaceholder;
@property JSValue *textDidChange;

// TODO: Deprecated and will be removed in later versions, use “text” instead
Expand Down Expand Up @@ -52,6 +53,7 @@
@property NSImage *icon;
@property (copy) NSString *text;
@property BOOL isInput;
@property (copy) NSString *inputPlaceholder;
@property JSValue *textDidChange;

// TODO: Deprecated and will be removed in later versions, use “text” instead
Expand Down
3 changes: 3 additions & 0 deletions Phoenix/PHModalWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ - (instancetype) init {
self.appearance = PHModalWindowControllerAppearanceDark;
self.hasShadow = YES;
self.text = @"";
self.inputPlaceholder = @"";
}

return self;
Expand Down Expand Up @@ -270,6 +271,8 @@ - (void) show {
self.window.hasShadow = self.hasShadow;

if (self.isInput) {
self.textField.placeholderString = self.inputPlaceholder;

// Required for text field to become key
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/api/17-modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Modal implements Identifiable
property Image icon
property String text
property boolean isInput
property String inputPlaceholder
property Function textDidChange

constructor Modal Modal()
Expand Down Expand Up @@ -46,6 +47,7 @@ end

- `hasShadow` property for whether the modal has a shadow, by default `true`
- `isInput` property for whether the modal behaves as an input modal, by default `false`
- `inputPlaceholder` property for the placeholder string that will be displayed when the input is empty, by default ``
- `textDidChange` callback function to call when the input modal’s text field value changes, receives the value as the first argument for the callback

## Constructor
Expand Down

0 comments on commit 881342f

Please sign in to comment.