first of all lets say that i searched quite a bit for an answer to this and wasnt able to find one.
i have a nstableview, with 5 columns, all with text field cells. one of these columns is a password column. i would like taht this column hides the typed chars. how can that be done? the only way i found by googeling was to insert a "image and text cell view", delete the picture and the textbox and enter a secure textbox. but i dont like this option because the password column would look different then the Others and if possible i would like to stay with the default appearance of a normal nstableview.
is this possible? if yes, how?
thanks!
Igor
Open your .xib file
In your TableView select the Text Cell you want to change to a "password" style
Go to Identity Inspector
In "Class" field replace NSTextFieldCell with NSSecureTextFieldCell
That's it :)
Related
If you rename a file in the Finder, the text field expands horizontally up to about the width of the column. And then it expands vertically up to three rows before scrolling. I'm assuming this has to be done in a text field outside the outline view. And I can get a text field to resize while I type. I just don't know how to place it over the outline view when necessary. And keep it pinned to the row if the outline view scrolls. Does anyone have any insights? Thanks!
Text editing is handled by a dedicated NSText and it’s called “field editor”. This shared single view is used for all text editing that happens in the window. It’s separate from what usually displays the text (when not editing).
Here are the docs:
https://developer.apple.com/documentation/appkit/nswindow/1419647-fieldeditor
As mentioned in the docs discussion section, you can use and customize another field editor. This should be a starting point for your task.
The window’s delegate can substitute a custom field editor in place of the window’s field editor by implementing windowWillReturnFieldEditor(_:to:). The custom field editor can become the default editor (common to all text-displaying objects) or specific to a particular text-displaying object (object).
NSControl docs also have a section about Field Editor that might help.
I'm wondering if there is a way to use Cocoa bindings to populate a cell-based NSOutineView whose cells are NSButtonCell of a button type, with both images and titles. So, one source of confusion is that I'm trying to provide 2 pieces of information for each cell, an image and a string.
The other thing that confuses me is that normally I think you'd populate a cell-based table by setting the value binding of the NSTableColumn. But if the column's prototype cell is NSButtonCell of a style other than radio button or checkbox, then the value binding disappears.
I came up with something that doesn't exactly answer the question I asked, but comes close enough for my purposes. Instead of using NSButtonCell, I use NSTextFieldCell, and insert the image beside the text as an attachment within an attributed string.
I have found that the text in a table view doesn't grow when the user resizes the column. (Or for that matter shrink if he shrinks the column, because the truncation ellipses then vanish.) Having gathered that this is something to do with constraints, my solution has been to uncheck Use Auto Layout (in the xib's file inspector). Not a big deal, but it comes just when I was beginning to think I might have mastered Autolayout.
Is that really the only way to do this?
The table is view-based, and gets its data from Core Data via an array controller. The text is displayed in an NSTextField.
It is as you have found out yourself.
If you want to know/learn more about NSTableview-behavior search for "TableViewVariableRowHeights" and "TableViewLinks" in Apples documentation and download the samples.
This question appears to be answered in:
How to Expand NSTableCellView Width When Resizing Column in NSTableView
summary: add horizontal constraints to the table view cell
see the link for screenshots
Quick question! When any NSFormCell becomes the first responder, its placeholder text becomes that of the last NSTextField to have focus. Here's an illustration: http://i.imgur.com/3dlzj.jpg
However, the NSTextFields never encounter this! Have you seen this before? This is happening in Xcode 4.3 — what thoughts do you have?
Thank you!
This isn't an answer, but just some further observations.
I did some experimenting with this, and it's not anything you're doing. If you just drag a form and a text field into a window in IB, and put a placeholder string in the text field, then that placeholder appears in the form if you first select the text field and then one of the form cells (with no code at all in the app). It doesn't matter whether you put any placeholder in the form in IB, it still gets the one from the text field. I also put a button in the window with an action that logs the placeholderString of one of the cells -- it always logs null, even though it shows the text field's placeholder. If you put a placeholder in that cell (in IB), then it logs that placeholder, but if you select the text field and then that cell, the text field's placeholder shows up, but the log still shows the original placeholder.
This looks like a bug to me. It might have something to do with the field editor? Isn't there a shared field editor for all text fields in a view?
I display a file list and want to show the file icon and editable file name in a NSTableColumn.
Also what would be the best way to display an additional NSImage immediately behind the file name (i mean not adding an additional column at the right side for the second icon).
Okay i found the answer to both questions after 10 more minutes of googling.
Apples sample code:
http://developer.apple.com/mac/library/samplecode/SourceView/Introduction/Intro.html
contains a NSTextFieldCell subclass named ImageAndTextCell which promises to do what i want.