Simple question, but I couldn't find the answer online. Is the a way to attach more than one method to a bar button action, as opposed to just one like:
barButton.action = #selector(method);
I know that I could create a new method that does everything I need to do an then assign the action to that method, but in my case, it would be a lot easier just to attach a second method to the action. Anyway, can it be done? Thanks
Related
jsbin
I am new to ember.js and trying to figure out the best way to accomplish an updatable list.
The list, inside a partial, is updated when a list item from another object is clicked. Is it better to save the clicked(chosen) items in a separate model? or is it better to use an array in the controller as I was trying to do in the above jsbin?
In either case, how is it accomplished? In my above attempt the totalValue seems to update fine, but the array does not which makes me think I was going about it wrong.
The chosenList is an array and ember array has it's own api methods in order to inform observes...
With this variation in your code, the property updates http://jsbin.com/eyatORO/3/edit
this.get('chosenList').addObject({
title:item.title,
value:item.value
});
Good Luck
I want to embed two generic buttons like "Select" and "Cancel" to CMFCPropertyGridCtrl property line. Is there a painless way to do that?
Found a solution myself. You can use OnCreateEditor virtual method to send a custom control to a property. Note, that it will be shown on property edit. Another important note, that CMFCPropertyGridCtrl calls OnCreateEditor each time the user edits the property but before the control is destroyed it deletes the last received CWnd object itself. You should consider that. I have found no notes about that in MSDN CMFCPropertyGridProperty documentation (you know what to say).
I am displaying a list of Document titles on the site's sidebar area. To achieve this I created a documents property on the App.SidebarController
Document = require '../models/document'
SidebarController = Ember.Controller.extend
documents: (->
Document.find()
).property()
module.exports = SidebarController
This works fine, when I create a new Document in my application, this sidebar property get's updated automatically and I don't know why. It works no matter what I put in the .property() function. e.g.
.property('Document')
.property('App.Document')
Can somebody explain how this works? What would be the correct thing for the property() function to observe?
So you are basically saying that is works, but you would like to know why.
Here is my guess: When your controller gets rendered, your computed property gets computed for the first time and an instance of an array is returned. When you create a new Document, i think this very same array is updated (= Document is added). So it does work despite the fact, that you do not specify a dependent key on property(). This is because the right array is already in place. As i said just a guess, but this seems like an understandable explanation.
And what would be the correct thing to do?
IMHO one should not use such Data Access methods directly in a computed property. Instead you should call this Data Access method inside a Route and then assign it to the controller. This way you make sure, that the find() method gets executed when needed.
Do action handlers not work directly on view instances?
Instead of attaching an action handler within the view, I want to attach it directly on the entire view itself.
Sample jsFiddle: http://jsfiddle.net/t3wdG/
UPDATE:
My goal is to delegate to specific functions (undo, redo in this case) on the parentView. The reason I have the buttonView is because on click on each button, I want to do something to it, for example add a css class to it.
So in effect, I want all my buttons to add a class to themselves on click and then delegate to separate functions on the parent view.
Is this possible using this approach?
Here is the updated jsFiddle: http://jsfiddle.net/xvkgk/
Ok, I don't think there is a built in ember way to do that, but check this jsfiddle, it seems work as you expect: http://jsfiddle.net/xvkgk/8/
The recommended solution is to make a custom view subclass. You can then add a click function the subclass that will handle click events automatically.
I've coded myself into a corner sort of with my data abstraction scheme and it's resulted in my needing editorOpened(QModelIndex) and editorClosed(QmodelIndex) signals in my views (QTableView almost exclusively).
The reason being that my data classes have automatic behavior that needs to be block/disabled during editing, then re-enabled afterwards.
At first I thought to try to do it with custom delegates but ran into problems for a couple reasons: one being just that it seems a bit excessive to use a custom delegate providing the same behavior for every single item, in other words it seems like it ought to be done for all items by the view itself. The second problem being that the delegates seem to be const which prevents me from setting an internal handle to the data object within the delegate.
Looking at the view methods, I found QAbstractItemView::edit and QAbstractItemView::closeEditor which would be perfect candidates for re-implementing with opened() and closed() signals, however I need an index/handle to the specific item being edited, which I don't think I can obtain from within those methods...
At this point I have no idea what else I could do. I'd appreciate any tips or pointers in the right direction! Thanks for reading
I solved it on my own...
I found QAbstractItemDelegate::editorEvent which is non-const (I must have not been looking as closely as I thought when reading the docs before).
I was able to set an internal handle in the custom delegate within this method, which allowed me to simply create a slot to do what I needed upon closing, and connect the closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint) signal to it.