sketchucation logo sketchucation
    • Login
    šŸ¤‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    WebDialogs: To sub-class or not?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 284 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Jim
      last edited by

      Just curious if anyone had any thoughts on creating webdialogs. I've seen 2 ways to use them: sub-classing and instancing:

      
      class MyDialog < UI;;WebDialog
      ...
      end
      
      

      or

      
      dlg = UI;;Webdialog.new({})
      
      

      Any advantages one way or the other?

      Hi

      1 Reply Last reply Reply Quote 0
      • Didier BurD Offline
        Didier Bur
        last edited by

        Hi Jim,
        Although I've only coded few WebDialogs, I'll vote for sub-classing. This is a good way for coding 'generic' attributes and methods if you have many other dialogs that will use them, by first extending the class.
        Regards,

        DB

        1 Reply Last reply Reply Quote 0
        • A Offline
          azuby
          last edited by

          a) subclassing and instancing
          b) instancing

          If you only need a window to display information, b) would do it. But if your dialog is more complex, subclassing seems to be a good choice, because you can let your class do a lot of things, i.e. generating the HTML by overriding the original set_html method:

          class AzubyDialog < UI;;WebDialog
            private
              def generate_html arg
                s = ''
                # TODO; implement your HTML generator code
                s
              end
            public
              def set_html arg
                super(arg.kind_of?(String) ? arg ; generate_html(arg))
              end
          end
          

          azuby

          *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

          Bad English? PM me, correct me. :smile:**

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement