0 Replies Latest reply on Dec 9, 2013 11:23 PM by Spike Projects

    Buttons prototype (UI Buttons VS pageItem Button)

    Spike Projects

      I'm confused:


      var w = new Window("palette");

      var b = w.add("button",undefined,"this is a UI button !");


      var s = app.activeDocument.selection[0];//current selection is a button (pageItem)


      b.constructor;//return Button()

      s.constructor;//also return Button()


      // and ..

      b instanceof Button;//return true

      s instanceof Button;//return true


      b.constructor == s.constructor;//return true !!! sure ??



      s.getElements()[0];//return [object Button]. ok. getElements is a Button (pageItem) method

      //b.getElements()[0];//return error: b.getElements is not a function. ok. b is a Script UI button.


      Button.prototype.whatButton = function(){

                return "hello !";



      b.whatButton();//return "hello !"

      s.whatButton();//also return "hello !"


      the problem is: when i add a prototype to Button class, prototype is applied both to the ScriptUI Button that the pageItem Button.


      the workaround is simple, but i think it's strange (bug?)...