Age | Commit message (Collapse) | Author |
|
Add the basic necessities for a document-based application. This is what
I came up with on 2023-09-10. The `DocumentWindowController` was just an
initial idea and doesn't do anything: we create the required window
controller in `Document`.
The `CFBundleDocumentTypes` entry enables us to interact with text
files.
This confirms that the "Open Recent" menu does get added automatically
below the "Open" menu.
|
|
* Remove the `NSTextFinder` code as it's not necessary to get a find bar
for an `NSTextView`.
* Remove the commented notes for the "Find" menu.
|
|
Add a find bar leveraging NSTextFinder. It turns out I didn't need to do
anything custom with `NSTextFinder` since `NSTextView` conveniently
already has a `usesFindBar` property to turn on built-in support for it.
I discovered that by looking at the TextEdit source code available here:
https://developer.apple.com/library/archive/samplecode/TextEdit/Introduction/Intro.html
I added an `NSScrollView` because you kind of need one to implement
`NSTextFinder`. Not sure if the finding functionality would still work
without the scroll view.
Also use the proper `-performTextFinderAction:` selector for the "Find…"
menu item to open the find bar.
Now we can confirm that the "Find" menu items work correctly.
|
|
This is done now.
|
|
I get the sense that the word order, particularly for the "Help" menu
item, may be different in other languages. Rather than force a certain
word order by concatenating strings, include the application name in the
localisation by making it a format string with an argument.
|
|
Don't think concatenating is the right approach here, but good enough
for now.
|
|
I miscopied this title when I was looking at a template MainMenu.xib in
Xcode.
While I was trying to make a test translation strings file using the
AppleGlot dictionaries, I discovered the mistake.
|
|
Make the menu items localization-capable by wrapping their titles in
`NSLocalizedString`.
Generate a base Localizable.strings file with `make genstrings`.
|
|
|
|
|
|
Just discovered this property which enables basic undo/redo
functionality on the NSTextView.
I can now confirm that the Undo and Redo menu bar items do in fact work.
|
|
|
|
Now that we have a working Font menu built by `NSFontManager`, we can
remove our custom Font menu code.
|
|
I don't understand why, but on Mac OS X 10.15, three menu items in the
automatically-generated Font menu don't have a Command key modifier.
Detect when this happens and add the modifier to the mask.
These menu items correctly had a Command key modifier when I tested the
code on macOS 13.
|
|
Do this so we don't have to bother with forward declarations.
|
|
Check if the Command key is included in the modifier mask. If not, then
add it.
|
|
|
|
This creates the whole font menu for me, and the actions work correctly,
very nice! Read about this in the `NSFontManager` documentation.
The only hitch is that some menu items don't appear to have the proper
keyEquivalents set. For example, "Show Colors", "Copy Style", and "Paste
Style" are all missing the Apple key from the shortcuts.
|
|
Turns out the problem was that I just didn't update the keyEquivalent
after copy-pasting this paragraph. Now it works correctly.
As for the tab bar menu items, it looks like those are inserted
automatically in an Xcode-generated app, so it isn't strange that
they're there.
|
|
|
|
|
|
Create the View menu based on MainMenu.xib. Need to investigate this
more, as some default menu items appeared even without me adding
anything to this menu. My menu has "Show Tab Bar" and "Show All Tabs"
even though I haven't added these. And it already had an "Enter Full
Screen" menu item without any shortcut tied to it, which appears to
override mine with a shortcut.
|
|
Add the actions based on MainMenu.xib that target First Responder.
The others require an NSFontManager, so I have to read up on what's
required for that.
|
|
Still need to set the actions on these menu items.
|
|
|
|
Don't have the actions yet, but this is the structure.
|
|
|
|
I learned about tags and that there are new names for the NSTextFinder
identifiers starting in 10.7. But these still don't seem to be doing
anything.
But I tried adding an NSTextView to a window in a base Xcode project and
the Find actions don't seem to work there either. So now that I have
this, I'm thinking the rest of the problem lies elsewhere. Perhaps the
NSTextView isn't connected enough to enable the Find actions.
|
|
|
|
Most options seem to work, except for Undo, Redo, and the Find commands.
|
|
|
|
This enables the "Close" menu item in the File menu and allows it to
work.
|
|
|
|
|
|
It seemed to work without this, but I figure it's better to be more
explicit.
|
|
|
|
The About, Hide, and Quit menu items all include the application name in
their titles.
|
|
These don't work yet, but this is the default list in a Cocoa
application created with Xcode.
|
|
Found out there's an `addItemWithTitle:action:keyEquivalent:` in
`NSMenu` that allows us to skip allocating the menu item ourselves.
|
|
|
|
Add functions that will create the menus in the application.
|
|
Forgot this when I added it.
|
|
Decided to use Core Foundation naming conventions here instead of
C-style lowercase. It seems to fit better with the Objective-C code.
|
|
Put the menu code in its own file to keep it more organised. We're also
going to be adding a lot more code here for the base main menu.
Wasn't sure if I should be releasing these menu objects, but it looks
like the application works when I do release them, so maybe
`setMainMenu` does a retain or copy.
I can't decide if I should use C-style identifiers or Foundation-style
in the menu file.
|
|
Move the window creation to a separate class, and also allow us to take
advantage of `NSApplicationDelegate` protocol methods.
|
|
Create a simple windowed Cocoa application with an application menu and
a "Quit" menu item.
|