strike through a selected row in NSTableView - objective-c

I am new to mac app.In my application i have booked history tableview.when the user click on "withdraw" button,I want to strike through the selected row of the tableview.And I am getting tableview content from NSArraycontroller.I don't know how to do it.If any one knows,guide me to do.
This is in mac osx,not in ios.

One way to obtain this would be to use a NSTextView inside your table cell and then bind the attribute string to you array controller. Now in the array controller you can change the relative value by adding an attribute of the type NSStrikethroughStyleAttributeName.

Related

Where can I bind column cell view controls?

I've been Googling for 3 hours, I can't find where to bind these things for Core Data in this textbook I'm reading. I just want to know where to find out where to bind it. I assume it's in the binding inspector after you highlight a column but under value it doesn't show anything like "Col 0 Image View" and for the first column I can't see a section that includes two places to set a binding which needs for an Image View and a Text Field. Below is an excerpt (as well as I can copy it) from the textbook Cocoa Programming for Mac OS X 4th Edition chapter 11, page 185.
"Now bind the value of each column's cell view control(s), as shown in the following table."
One of the entries in the table is:
Binding valueof Col 0 Image View
Bind to Table Cell View
Controller Key Empty
Key Path objectValue.photo
So after a day's work of searching and random clicking I found this rather elusive, yet out-in-the open binding. I hope this helps anyone else who might be frustrated.
This is where to find it, you want to click the one that shows what I have circled. Open the bindings inspector and then it'll pop up with objectValue already populated in your key path.
The first column has two since it has an image view and text view. Make sure to select the appropriate one for whichever one you want bound.

NSTableView display selected row into NSTextField

I'm a still newbie in cocoa and I've already created NSTableView with buttons to add and remove selected rows. I added NSTextField label to display the values from selected row of the two columns.
Can anyone point me into right direction how to achieve this? I guess that it should work like this:
get selected row index number
get string value of both identifiers in selected row
set string value
also there should be if nothing is selected the string is empty I guess.
Found what I was looking for about the NSTableView bindings.
https://developer.apple.com/library/mac/#samplecode/NSTableViewBinding/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010522-Intro-DontLinkElementID_2

NSTableView selected row highlight

I have a NSTableView with two columns, one is NSButtonCell and the other is a NSTextFieldCell. The text in NSTextFieldCell cannot be edited but the user can select a part of the text and make it bold. The current implementation is to allow them to do a double click and select a part of the text. The problem is, once the user is done bolding, the highlight color at selected row still persists.
The NSTableView usually has variable number of rows each time. I cannot do SelectRow as false as I need to be able to select the row. I also need to support 10.5.8 so I cannot set - NSTableViewSelectionHighlightStyle as None.
My application is a Cocoa application, which needs to run on 10.5.8, 10.6 and 10.7.
You can try setting the selected row as false. NSTableView has a method deselectRow. After bolding is done, you can deselect the row.

How to show button cell (check box) title in table view, using bindings

I am trying a simple application where I have a mutable array of mutable dictionaries, such as -
NSMutableDictionary *sample6 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:#"title6",#"title",[NSNumber numberWithBool:NO],#"state", nil];
In IB I created a table view with NSButtonCell (check box).
I was able to show checkboxes state (checked or unchecked), using following table column bindings:
Value - ArrayController.arrangedObjects.state
In this case it shows an array of checkboxes with title - "Check" as shown in below screen-shot:
Now my aim is to show checkboxes title using bindings, such that it
gets value from same mutable dictionary from which it is getting its
state.
I tried following binding for button cell but it did not work:
title -> ArrayController.selection.title
I also tried this binding for button cell :
title -> ArrayController.arrangedObjects.title
but it didn't work, it appeared like this after using above binding:
Can any one suggest me which controller key to use and if this is not the correct way to show titles then what is the correct way to do so?
Unfortunately you'll need to write a little code if you want to do it this way. When binding table column values to an array, the table column is handling taking the prototype data cell, setting its values, and "stamping" it in place for each row. The button cell's bindings aren't exposed "through" the table column, so a simple binding won't do it for you.
To Answer Your Question
So. Since only the value binding is exposed, the title must be set manually if you really want the checkbox's title to reflect the value (ie, you really want the checkbox to handle both the check state and displaying the title). To do this, you have to mix bindings with < NSTableDelegateProtocol > . Use the -tableView:willDisplayCell:forTableColumn:row: method to set the cell's -title property to that of the proper object in your array controller's -arrangedObjects array each time you're asked. Mixing bindings and data source / delegate methods is actually quite common for more than the most basic applications, so don't worry that you're doing something dirty. Note: you won't be able to support editing the title by doing this since it's a checkbox.
An Alternative Design
Personally, I'd avoid all that and just add a separate table column for the title. Bind the new column's value to the array controller's arrangedObjects.title and turn off the checkbox button cell's title so only the checkbox itself is displayed. That simplifies the whole thing greatly and allows editing the title.

How to add a checkbox in front of folder tree in finder with Mac?

I want to change a outline view , and add checkbox cell in front of node , and the node have a icon and how to add checkbox in head of the icon?
Download the DragNDropOutlineView sample code from Apple and have a look. It contains all the features you're looking for.
As for adding cells, think of it more in terms of adding columns (a column is designed to hold one cell of a single type). If you want more controls in each row, add a new column and set its cell type. Both of these actions can be performed easily in Interface Builder. You can select the table and increase its column count by one (a new column will appear), move the column where you want it (to the beginning), and drag a checkbox-configured button cell (there's a checkbox cell in the IB palette) into the body of the column and its "data cell" prototype will be set. That's it. Just wire it up as you normally would (NSTableViewDataSource or Cocoa Bindings) and you're done.