Tests/Manual/People: Add Bold and Italic to the Notes contextual menu

This commit is contained in:
David Richardson committed 2026-11-26 16:15:06 -06:00
1 parent 6090dece37
commit 6ae0a7165f
2 files changed
+33 -2

No files matched your search

@@ -37,6 +37,7 @@
* with the attributedString binding. The binding updates the person as the text changes, so
* the table's notes icon follows the typing. CPTextView has no editable binding, so the
* controller sets its editable state, and the scroll view's border, when the mode changes.
* As the text view's delegate, the controller adds Bold and Italic to its contextual menu.
*
* The Tags row holds a CPTokenField bound to the person's tags, an array of free-form strings.
* Typing a comma or Return ends a token. As the controller is the token field's delegate, it
@@ -379,6 +380,7 @@ PersonDetailMinimumWidth = PersonDetailPreferredWidth - FieldWidth + ShortFie
[_notesView setHorizontallyResizable:NO];
[_notesView setVerticallyResizable:YES];
[_notesView setAutoresizingMask:CPViewWidthSizable];
[_notesView setDelegate:self];
[_notesScrollView setDocumentView:_notesView];
var options = [self _placeholderOptions];
@@ -649,6 +651,31 @@ PersonDetailMinimumWidth = PersonDetailPreferredWidth - FieldWidth + ShortFie
});
}
// ---------------------------------------------------------------- Notes delegate
/*
Adds Bold and Italic to the contextual menu of the Notes text view, after its Cut, Copy and
Paste. The text view's menu does not validate its items itself, so each item takes its
enabled state and its check from the text view: enabled in edit mode, and checked when the
text at the start of the selection is bold or italic.
*/
- (CPMenu)textView:(CPTextView)aTextView menu:(CPMenu)aMenu forEvent:(CPEvent)anEvent atIndex:(CPUInteger)anIndex
{
[aMenu addItem:[CPMenuItem separatorItem]];
var styles = [[@"Bold", @selector(bold:), @"b"], [@"Italic", @selector(italic:), @"i"]];
for (var i = 0; i < styles.length; i++)
{
var item = [aMenu addItemWithTitle:styles[i][0] action:styles[i][1] keyEquivalent:styles[i][2]];
[item setTarget:aTextView];
[item setEnabled:[aTextView validateUserInterfaceItem:item]];
}
return aMenu;
}
// ---------------------------------------------------------------- Layout helpers
// Centres aView vertically on the midline of row aRow of a section.
+6 -2
View File
@@ -75,6 +75,8 @@ existing action. If the application routes its actions through the responder cha
should be nearly trivial to add. Together they exercise the kind of interface that is difficult
to build with a web component framework.
People is kept to these items. The items marked Pending are deferred, with no date.
### Detail pane
1. Edit history. Pending; only the Reject button below is in place. This needs a change to
@@ -91,8 +93,10 @@ to build with a web component framework.
- The time is stored in UTC and shown in local time, in conversational form.
2. When no single row is selected, a covering view over the detail pane says
"Please select a single row to edit or display."
3. The contextual menu of the Notes field adds the selection commands and basic style commands.
Planned after the column sizing switch (item 13).
3. The contextual menu of the Notes field adds Bold and Italic after Cut, Copy and Paste. They
are enabled in edit mode, and each is checked when the text at the start of the selection
has the style. Choosing a checked item removes the style. A right click in Notes makes it
the first responder, so the commands act on the notes.
Details has a Tags row: a CPTokenField bound to the person's tags, an array of free-form
strings. A comma or Return ends a token, and the field offers completions from the tags in use,