[MacRuby] #274: [HotCocoa] Button images
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Attached patch adds the image=(img), alternate_image=(img) and image_position=(pos) methods into NSButton to allow setting images on creates. -- Ticket URL: <http://www.macruby.org/trac/ticket/274> MacRuby <http://macruby.org/>
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by eloy.de.enige@…): Hi, I just closed #273 which does the same thing as this patch does for #image=. That is, the setImage method is already available as #image=. About the other two I have my reservations. My question with changes like these is: where lies the limit of what will be mapped. As I have understood from Rich, the point is to make the “harder” to use Cocoa APIs more accessible, in a more Ruby-ish way. But is writing “alternate_image=” vs “alternateImage=” really necessary and helpful? I'd be inclined to say no. Sooner or later people will have to deal with the existing API, so there's not much point in trying to completely mask the fact that the dev is using Cocoa. However, where the limits should lie is not written in stone somewhere afaik, so maybe that's a good idea to discuss? My 2$ -- Ticket URL: <http://www.macruby.org/trac/ticket/274#comment:1> MacRuby <http://macruby.org/>
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by dj2@…): The reason I've been adding the _'d names is for consistency. There are a bunch of mappings already that translate the camel case versions to the underscore version. Having to try to remember which methods are camel case and which are underscore would be a pretty annoying barrier to put in place when working with HotCocoa. I'm not trying to mask using cocoa, but when I'm creating a box I don't really want to see box(:title_position => :above_top, :alternateTitle => "blah"). Seems inconsistent to me. -- Ticket URL: <http://www.macruby.org/trac/ticket/274#comment:2> MacRuby <http://macruby.org/>
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by eloy.de.enige@…): Right, I understand that, but this is going to be true for a whole lot of methods. So my question (to anyone) remains; where lies the limit of what kind of APIs should be mapped? -- Ticket URL: <http://www.macruby.org/trac/ticket/274#comment:3> MacRuby <http://macruby.org/>
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by rich@…): Here is what I propose (with input from Laurent): When you use the hash of symbol => values in the construction of a hotcocoa mapped class internally what happens is some of the symbols/values are extracted by the constructor (like :frame, :layout, etc). The rest are iterated over inside the hotcocoa code to see if the instance respond_to?(:symbol=). If so, it calls that method. What I propose is to add additional logic which checks for setSymbolMethod, converting the underscored parameter into a camelcase setter and if it respond_to?(:setSymbolMethod) it dispatches. These will really clean up the mapping files because we can then remove things like movie_view's: def fill_color=(color) setFillColor(color) end With this change passing: movie_view :fill_color => color(:red) Will just work without that mapped method. This solves Dan's problem, and I think keeps hotcococoa cleaner. This will just be a documented behavior of construction with the hash parameter list. -- Ticket URL: <http://www.macruby.org/trac/ticket/274#comment:4> MacRuby <http://macruby.org/>
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by eloy.de.enige@…): Sounds great! -- Ticket URL: <http://www.macruby.org/trac/ticket/274#comment:5> MacRuby <http://macruby.org/>
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by mattaimonetti@…): As per our discussion via IM, I agree with Rich's suggestion. One note tho, while we will document that behavior in the Cocoa/HotCocoa doc app, calling #methods on an object won't list this dynamic methods. -- Ticket URL: <http://www.macruby.org/trac/ticket/274#comment:6> MacRuby <http://macruby.org/>
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: ---------------------------------+------------------------------------------ Comment(by lsansonetti@…): I think it's okay if #methods does not list these helpers, since they are only used in the mapping constructors. -- Ticket URL: <http://www.macruby.org/trac/ticket/274#comment:7> MacRuby <http://macruby.org/>
#274: [HotCocoa] Button images ---------------------------------+------------------------------------------ Reporter: dj2@… | Owner: lsansonetti@… Type: enhancement | Status: closed Priority: minor | Milestone: Component: MacRuby | Resolution: fixed Keywords: | ---------------------------------+------------------------------------------ Changes (by rich@…): * status: new => closed * resolution: => fixed Comment: added constant map from this patch -- Ticket URL: <http://www.macruby.org/trac/ticket/274#comment:8> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby