sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    WebDialogs - The Lost Manual — R1 09 November 2009

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    43 貼文 13 Posters 22.7k 瀏覽 13 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • thomthomT 離線
      thomthom
      最後由 編輯

      @tbleicher said:

      @thomthom said:

      You won't be able to use HTML5 in webdialogs - not until IE adds support for it.

      I am using excanvas http://code.google.com/p/explorercanvas/ which provides a canvas object in IE.

      Thomas

      That's very interesting! I've been wanting for a good solution to dynamically draw graphics in webdialogs. Probably be of interest for Whaat as well... ...thinking Profile Builder...

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 條回覆 最後回覆 回覆 引用 0
      • J 離線
        Jim
        最後由 編輯

        And just to have more options, there is also chrome frame.

        Hi

        1 條回覆 最後回覆 回覆 引用 0
        • thomthomT 離線
          thomthom
          最後由 編輯

          @jim said:

          And just to have more options, there is also chrome frame.

          Yea, but this requires the user to install a browser plugin.
          explorercanvas is a simple JS library which the developer includes in the project without the user ever having to install any browser extension. That's what's appeal to me.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 條回覆 最後回覆 回覆 引用 0
          • P 離線
            Pout
            最後由 編輯

            this seems to be very interesting
            Have to dig into this.

            1 條回覆 最後回覆 回覆 引用 0
            • chrisglasierC 離線
              chrisglasier
              最後由 編輯

              One thing driven discovered was that if for some reason there is whitespace as here -

              cmd = "fImportReturn('#{array}');"
              @dlg.execute_script (cmd)
              
              instead of
              
              @dlg.execute_script(cmd)
              
              
              

              it is OK on PCs but not Macs. This maybe of interest to coders who use this style (Jim).

              With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

              1 條回覆 最後回覆 回覆 引用 0
              • J 離線
                Jim
                最後由 編輯

                Would a kind Mac user (or 2) open the Ruby Console, and give the result from entering:

                $VERBOSE

                and

                $DEBUG

                and

                $-w

                Hi

                1 條回覆 最後回覆 回覆 引用 0
                • thomthomT 離線
                  thomthom
                  最後由 編輯

                  @jim said:

                  Would a kind Mac user (or 2) open the Ruby Console, and give the result from entering:

                  $VERBOSE

                  and

                  $DEBUG

                  and

                  $-w

                  
                  > $VERBOSE
                  false
                  > $DEBUG
                  false
                  > $-w
                  false
                  
                  

                  SU 7.1.6859
                  OSX 10.4

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 條回覆 最後回覆 回覆 引用 0
                  • Dan RathbunD 離線
                    Dan Rathbun
                    最後由 編輯

                    By the way.. we have no control over C-implemented Ruby objects, that incorrectly call the wrong C 'warn'/'warning' function, ie: don't respond to the setting of $VERBOSE ( called ruby_verbose in C.)

                    If you find one, it would need to be reported on RubyForge.net

                    I'm not here much anymore.

                    1 條回覆 最後回覆 回覆 引用 0
                    • chrisglasierC 離線
                      chrisglasier
                      最後由 編輯

                      @mmyoung said:

                      I was never able to get Matt666's PointTool.rb to work on my Mac. I opened it in a text editor and removed the "=begin" and "=end" lines at the beginning and placed a "#" at the beginning of each comment.

                      Now it runs on Mac.

                      This may be relevant here as well.

                      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                      1 條回覆 最後回覆 回覆 引用 0
                      • D 離線
                        driven
                        最後由 編輯

                        @chrisglasier said:

                        This may be relevant here as well.

                        hi,
                        some Mac bits...

                        @Jim I get false, false, false

                        @Dan #!ruby warn_ovr.rb returns nil

                        whitespace handling is strange, not consistent from script to script, some work with whitespace , but all work without it...

                        the =begin; =end seems to be dependent on what editor the file was last saved in....

                        I never had a problem if I had a look with xCode, but when I first used Smultron the syntax colouring for '=' commenting is off by default, and very oddly appears to effect how SU then sees some of the files saved from this state...

                        It took a while to figure out, but all affected files worked after changing the syntax colouring option to on and re-saving. Re-saving from xCode also 'fixed' them, which was my only 'clue' of what was happening.

                        Something that came up proof positive last week (and I'm trying to find a test for), is that not all Macs are handle syntax the same

                        there was an issue with one of TIG's scripts and it seems that Mac's running Developer Tools have much stricter syntax prerequisite.

                        I did a mini survey of systems 'failing' and we all had different mixes of OSX, Ruby, Gems, editors but all had DevTools

                        a Variety of Macs without were fine but those with Xcode were failing to run the script, TIG found a solution for his script, but the consistency of the Pass/Fail leads me to think it may make a good test tool... when I know how...

                        On another point anyone know of a .json to/from .skp or collada convertor for Mac?

                        john

                        learn from the mistakes of others, you may not live long enough to make them all yourself...

                        1 條回覆 最後回覆 回覆 引用 0
                        • J 離線
                          Jim
                          最後由 編輯

                          Just a small note mentioning a file-based dialog need not use the .htm or .html extension - any filename used in set_file will work.

                          For example, this works just fine:

                          @dlg.set_file("user_interface.dlg")

                          Although clearly the contents need to be HTML, the filename extension does not matter.

                          Hi

                          1 條回覆 最後回覆 回覆 引用 0
                          • Dan RathbunD 離線
                            Dan Rathbun
                            最後由 編輯

                            @driven said:

                            @Dan #!ruby warn_ovr.rb returns nil
                            john

                            @John..
                            The first line is a boo-boo, should have taken out all of the unix-like load directive. (The file is not meant to run from the command line anyway. It was meant to be a 'require' script.)

                            I'm rewriting that now as a Mix-In Module, rather than an override to module Kernel. (Backward compability issues, and so forth.) It would be 'forever' before we would hope to see any changes or additions to the Kernel module anyway, with all the other things they need to fix. (I had to laugh when I saw that Ruby 2.0 was due, or estimated to be complete 01/19/2038.)

                            I'm not here much anymore.

                            1 條回覆 最後回覆 回覆 引用 0
                            • Dan RathbunD 離線
                              Dan Rathbun
                              最後由 編輯

                              @jim said:

                              Would a kind Mac user (or 2) open the Ruby Console, and give the result from entering:

                              **$DEBUG**
                              The 'Pick-Axe' book says falseis the default.

                              @jim said:

                              **$VERBOSE** [alias] **$-w**
                              The 'Pick-Axe' book says falseis the default and known as 'medium mode'.
                              When set to nil, it is 'silent mode'; when set to true, it is 'verbose mode'.

                              The reason for the $-w alias 'flag', is that $VERBOSE is [supposed to be] the conditional argument used by warnings. But, something's fishy..

                              (from Ruby.h, ver 1.8.6, line 562..564, Language="C" )
                              %(#008B8B)[void rb_warning __((const char*, ...)); /* reports if-w' specified /
                              void rb_sys_warning __((const char
                              , ...)); /* reports if -w' specified */ void rb_warn __((const char*, ...)); /* reports always */]

                              So.. rb_warn is NOT supposed to check $VERBOSE, and rb_warning IS.
                              What's weird is that the Ruby method Kernel.warn is documented as if it calls rb_warning, instead of rb_warn; and the Core RDoc actually gives two internal examples, one in Pure Ruby (see it) and one in C (see it) that are written to act like rb_warning is supposed to act. (Note, the C example is really named 'rb_warn_m'.)

                              But in practice... I find that Kernel.warn acts like rb_warn is supposed to act, and it does not matter what $VERBOSE is set to. The message is always sent to $stderr.

                              This has forced me to make my 'warn' calls work the way they should, by doing this:
                              # Send warning only if in Verbose mode
                              warn('My Informational Message') if $VERBOSE

                              # Send warning unless in Silent mode
                              warn('My Important Message') unless $VERBOSE.nil?

                              # Send warning no matter what Verbose mode
                              warn('My Critical Message that MUST be displayed!')

                              BUT.. I'm sick of doing this workaround!

                              I want to make three warn methods, that work the way they should.
                              Firstly, the current warn needs to be renamed old_warn (or something else.)
                              And define a replacement warn! that has typechecking, and returns true if no IO error occurs. (The original just returned nil.)
                              Then define a new warn, that displays (returns true,) unless in Silent mode (returns false.)
                              Third define a new warn?, that checks and only displays if $VERBOSE is true (and returns true, otherwise returns false.)
                              (If there's any problem with the $stderr IO object, an Exception should be raised by the object itself.)
                              Example Ruby override code: ### under REVISION to a Mix-In Module ###

                              
                              # file warn_ovr.rb
                              
                              # Make Warnings work the way they should.
                              #
                              # by; Dan Rathbun - 16 MAR 2010 - Palm Bay, FL, USA
                              #
                              # TERMS; Public Domain
                              
                              module Kernel  ##<<----<<< this will change in next Revision
                              
                                ### under REVISION to a Mix-In Module with a different module name
                              
                                # alias the old warn method
                                alias_method(;old_warn,;warn)
                              
                                # warn! will always send to $stderr
                                # regardless of $VERBOSE setting
                                def warn!(msg)
                                  unless msg.is_a?(String)
                                    raise(TypeError,'String argument expected.',caller(1))
                                  end
                                  $stderr.write(msg + "\n")
                                  return true # no IO error occured
                                end
                              
                                # warn will now send to $stderr
                                # ONLY if $VERBOSE is not Silent mode (nil)
                                def warn(msg)
                                  unless msg.is_a?(String)
                                    raise(TypeError,'String argument expected.',caller(1))
                                  end
                                  unless $VERBOSE.nil?
                                    $stderr.write(msg + "\n")
                                    return true
                                  else
                                    return false
                                  end
                                end
                              
                                # warn? will send to $stderr
                                # ONLY if $VERBOSE is in Verbose mode (true)
                                def warn?(msg)
                                  unless msg.is_a?(String)
                                    raise(TypeError,'String argument expected.',caller(1))
                                  end
                                  if $VERBOSE
                                    $stderr.write(msg + "\n")
                                    return true
                                  else
                                    # We return false if $VERBOSE is nil or false
                                    return false
                                  end
                                end
                              
                              end # Kernel
                              
                              

                              EDIT: Code changed.

                              • Sketchup has .puts as private, changed to using $stderr.write* cleaned up code a bit; more readable.
                                Question, I set raise to remove the last item from the callstack. Not sure if this is correct or not?

                              I'm not here much anymore.

                              1 條回覆 最後回覆 回覆 引用 0
                              • M 離線
                                marksup
                                最後由 編輯

                                I became alarmed at the significant differences in the appearance of my WebDialogs depending on the active browser (IE9, IE8, Chrome or Firefox) and so, based on the excellent advice above, added the following to my HTML...

                                <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
                                'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
                                <html xmlns='http://www.w3.org/1999/xhtml' xml;lang='en'><head><meta http-equiv='X-UA-Compatible' content='IE=8; charset=iso-8859-1'/></head>
                                

                                This did wonders for the consistency, but as a direct result my <body scroll='no'> statement became ignored and a vertical scrollbar appeared. This was solved by using <body style='overflow-y:hidden'> instead.

                                I also lost the use of 1.chr as the first space for textarea text - since 32.chr (the standard space) had always been ignored (except on a MAC!).

                                Of more interest now... how to invalidate the maximise option (i.e. to keep the WebDialog panel at the original specified size) since max_width and max_height don't perform this function. Has anyone a suggestion?

                                1 條回覆 最後回覆 回覆 引用 0
                                • thomthomT 離線
                                  thomthom
                                  最後由 編輯

                                  @marksup said:

                                  Of more interest now... how to invalidate the maximise option (i.e. to keep the WebDialog panel at the original specified size) since max_width and max_height don't perform this function. Has anyone a suggestion?

                                  By setting the resize argument of WebDialog.new.

                                  Thomas Thomassen — SketchUp Monkey & Coding addict
                                  List of my plugins and link to the CookieWare fund

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • Dan RathbunD 離線
                                    Dan Rathbun
                                    最後由 編輯

                                    @marksup said:

                                    ..., but as a direct result my <body scroll='no'> statement became ignored and a vertical scrollbar appeared. This was solved by using <body style='overflow-y:hidden'> instead.

                                    @marksup said:

                                    I also lost the use of 1.chr as the first space for textarea text - since 32.chr (the standard space) had always been ignored (except on a MAC!).

                                    (a)

                                    You MIGHT be able to use named entities (NE) or numeric character references (NCR), see:

                                    • [ISO Latin-1 Character Set](http://msdn.microsoft.com/en-us/library/aa752007(v)
                                    • [Additional Named Entities for HTML](http://msdn.microsoft.com/en-us/library/aa752008(v)
                                    • [Character Entities for Special Symbols](http://msdn.microsoft.com/en-us/library/ms537499(v)

                                    Their use may depend upon if the textArea object's canHaveHTML property is true
                                    nbsp = ' ' # non-breaking space
                                    or
                                    nbsp = ' ' # non-breaking space
                                    note: 32.chr is ' '

                                    If you need more than 1 space (say 4 spaces,) do this to append spaces to your html:
                                    html = '' # start with empty html string html << nbsp * 4 html << textline
                                    .. etc ... then:
                                    wd.execute_script("document.getElementbyID('myTextArea').innerText='#{html}';")

                                    • or perhaps use methods: [insertAdjacentHTML](http://msdn.microsoft.com/en-us/library/ms536452(v) or [insertAdjacentText](http://msdn.microsoft.com/en-us/library/ms536453(v)

                                    (b)

                                    Or perhaps you can use escaped characters, see:
                                    [Special Characters (Windows Scripting - JScript)](http://msdn.microsoft.com/en-us/library/2yfce773(v)

                                    (c)

                                    The last alternative is to use padding or margin properties for your textArea object:

                                    • [marginLeft](http://msdn.microsoft.com/en-us/library/ms530804(v)* [paddingLeft](http://msdn.microsoft.com/en-us/library/ms530835(v)

                                    I'm not here much anymore.

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • Dan RathbunD 離線
                                      Dan Rathbun
                                      最後由 編輯

                                      @marksup said:

                                      I became alarmed at the significant differences in the appearance of my WebDialogs depending on the active browser (IE9, IE8, Chrome or Firefox) and so, based on the excellent advice above, added the following to my HTML...

                                      <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
                                      > 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
                                      > <html xmlns='http://www.w3.org/1999/xhtml' xml;lang='en'><head><meta http-equiv='X-UA-Compatible' content='IE=8; charset=iso-8859-1'/></head>
                                      

                                      This did wonders for the consistency, but as a direct result my <body scroll='no'> statement became ignored and a vertical scrollbar appeared. This was solved by using <body style='overflow-y:hidden'> instead.

                                      @unknownuser said:

                                      (http://msdn.microsoft.com/en-us/library/ms535205(v)":rkw7axk6]In standards-compliant mode, the html element represents the entire surface onto which a document's contents can be rendered. When the !DOCTYPE declaration does not specify standards-compliant mode, and with earlier versions of Internet Explorer [< IE6,] the body object represents the entire surface onto which a document's contents can be rendered.

                                      ... so when using standards-compliant mode, you can use:
                                      <html scroll='no'>
                                      .. or if you prefer to use the overflow-y property:

                                      @unknownuser said:

                                      (http://msdn.microsoft.com/en-us/library/ms530829(v)":rkw7axk6]With Microsoft Internet Explorer 6 and later, when you use the !DOCTYPE declaration to specify standards-compliant mode, this property applies to the html object.

                                      You can handle both situations by creating a STYLE tag (or load a separate .css file,) and apply it to both the HTML and BODY elements. here's a snippet:

                                      <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
                                      'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
                                      <HTML xmlns='http://www.w3.org/1999/xhtml' xml;lang='en'>
                                        <HEAD>
                                          <META http-equiv='X-UA-Compatible' content='IE=8'/>
                                          <MEAT http-equiv='Content-Type' content='text/xhtml; charset=iso-8859-1'/>
                                          <META http-equiv='MSThemeCompatible' content='Yes'>
                                          <STYLE>
                                            html,body { overflow-y ; hidden; }
                                          </STYLE>
                                        </HEAD>
                                        <BODY>
                                          <!-- your body here -->
                                        </BODY>
                                      </HTML>
                                      

                                      I'm not here much anymore.

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • Dan RathbunD 離線
                                        Dan Rathbun
                                        最後由 編輯

                                        @thomthom said:

                                        Note! Because WebDialogs are embedded browser controls they behave differently than a normal website on Windows. Internet Explorer 8, as a browser, will default to Super Standard mode when you use Strict DOCTYPE. But when embedded as a WebBrowser object it will default to IE7 compatibility mode.

                                        Yes I have noticed this... I used a Strict DOCTYPE, and set the compatibilty mode to "EmulateIE8", but %(#8000BF)[document.documentMode] still returns "7". (dang it!)

                                        @thomthom said:

                                        Microsoft says that you have to set a registry key for the application that embeds the WebBrowser to make it use IE8 rendering mode.

                                        I cannot find reference to this registry key... do you still have a link ?

                                        @thomthom said:

                                        But of course we can't do that for Sketchup since some plugins might rely on the IE7 mode.

                                        I CAN (and need to,) because I am writing a subclass that will expect Strict mode, with the highest compatibility under MSIE, so as to take advantage of CSS3 and HTML5, if available.

                                        @thomthom said:

                                        But what you can do is include the meta tag <meta http-equiv="X-UA-Compatible" content="IE=8"/>. Note that this meta tag should be placed at the top of the <head> tag.

                                        Beware that the user agent string will still report MSIE 7.0 for embedded WebBrowsers - even though you use IE8 mode. This differs from when you test the same HTML in the normal web browser where it returns MSIE 8.0. To check the rendering mode: document.documentMode.

                                        Even using this tag along with a proper DOCTYPE tag, does not run the WebDialog in IE8 mode. Certain CSS 2.1 properties (as well as Transitional CSS3 properties available to IE8 and higher,) are not being honored.

                                        The min-width, max-width, min-height and max-height CSS properties are the ones I am wanting to use, mostly that are not honored.

                                        I'm not here much anymore.

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • thomthomT 離線
                                          thomthom
                                          最後由 編輯

                                          Got some sample code there Dan?
                                          I have Edge mode working in my dialogs by just adding the meta tag and valid markup. Using the latest HTML5 and CSS3 features of IE10.

                                          Thomas Thomassen — SketchUp Monkey & Coding addict
                                          List of my plugins and link to the CookieWare fund

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • Dan RathbunD 離線
                                            Dan Rathbun
                                            最後由 編輯

                                            I think the major problem is that the "%WINDIR%/system32/shdocvw.DLL" on my machine is old. It's version: 6.0.2900.5512

                                            But on mother's XP machine (that has automatic updates ON,) it's newer, version: 6.0.2900.5770
                                            (EDIT: Looks like this machine had 963027 applied, and mine did not.)

                                            .. so I missed an update, no doubt. (I'm using the mskbfiles site to try and track down updates I need to apply.)

                                            Comparing to IE9/10 does not help my XP machines. I'm dealing with IE8, right now.

                                            I'm not here much anymore.

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement