Dialog - Simple WebDialog Communication Underware
-
I have figured out the WebDialog stuff. It has not been easy. It felt, at first, and still feels like an unnecessarily asymetric something that @Last pushed out under deadline pressure. I've been thinking, under no deadline pressure, about how it could be made simple and symetric.
The following is my design. Goal: something small, simple but not limiting. Critiques are welcome. Suggestions for improvement are welcome. Offers to help are very welcome indeed!
--- Informally ---
Dialog is a Ruby class and a JavaScript object. Both have the same API. Both ends, Ruby and JavaScript, know the other end as "partner." (There is no "up" nor "down.")
A pair of methods, "toPartner()" and "fromPartner()" handle queue-based message communication. Each end has a queue of waiting messages. Each end has a "numMessages()" method.
The "toPartner()" method may also call a named partner routine, bypassing the queue. Partners add named routines via the "addListener()" method. (Note: some may choose to use named partner routines exclusively, never using the queue.)
One utility function, "test()", also exists. It returns true if communication is working both ways.
--- A bit more formally ---
addListener( name, listener )
// "listener" is code to call for a "name"-type messagestring fromPartner()
// pops next message from queue
// throws "No Messages" if queue is emptyint numMessages()
// # of messages in queueboolean test()
// if true, you are successfully communicatingtoPartner( [name,] message )
// sends "message" to partner
// "name" is the name of a partner-end listener
// queue is used if "name" is not supplied
// throws "No Partner" if message is not acknowledged.
// throws "No Listener" if partner does not have a "name" listener -
@martinrinehart said:
I have figured out the WebDialog stuff. It has not been easy. It felt, at first, and still feels like an unnecessarily asymetric something that @Last pushed out under deadline pressure. I've been thinking, under no deadline pressure, about how it could be made simple and symetric.
The following is my design. Goal: something small, simple but not limiting. Critiques are welcome. Suggestions for improvement are welcome.
Suggest you stick to your previous goal.
@martinrinehart said:
I'm identifying a small subset of Ruby that is suitable for teaching beginning programmers and then using that language subset to create geometry. For "UI" we'll put pseudo-constants into the beginning of each Ruby and then edit the code:
# stairs.rb > RISE = 7 > RUN = 9 > NSTEPS = 14 > ... >
Going farther requires Ruby, HTML, CSS and JavaScript - too much for a tutorial on SketchUp modeling.
Chris
-
@chrisglasier said:
@martinrinehart said:
Suggest you stick to your previous goal.
That project is well underway, thank you. Problem is, if you try to write 12 hours a day, your stuff has all the sparkle of week-old soda.
Why has no one commented on the substance? Are you all much happier with the existing situation than I am, or much less sanguine about working a serious improvement?
-
I have the last couple of weeks implemented a webdialog for my selection toys. And yesterday I fired up my old mac to do some testing.
Needless to day, it was a frustrating day.I ran into syncing problems due to the async nature of the Mac WD. But fortunately for me I could merge all the .execute_script commands into one. (I was sending multiple JSON objects - I just merged them into one big one.) And the dialog never send any commands back except for when it's ready, and for the OK and Cancel buttons. So I've managed to avoid the big pains with this.
But now that I've had a chance to experience WebDialogs on Mac I'm also looking for a solution to the async problem.
-
@unknownuser said:
'We' could crate a 'community' extension to the webdialogs, that would add: sliders, multiple selection, radio and check boxes. Even if there wouldn't be much control over a layout, we would have one solution tested on both platforms and 'community' driven.
Tomasz
Your idea could fit well with Jim and I's current development that started life here and picked up speed with Alex's cheat-sheet (link below)
Chris
-
I would love to see some form of improvement to the Webdialogs. I have tried them with my SU2KT exporter, when I wanted to have a multiple selection from a list. It is hard for me to learn HTML and JS and CSS and ... I have given up for a while.
'We' could crate a 'community' extension to the webdialogs, that would add: sliders, multiple selection, radio and check boxes. Even if there wouldn't be much control over a layout, we would have one solution tested on both platforms and 'community' driven.
Thanks for your efforts Martin
Tomasz
-
I would be forever indebted to whoever created such a project. I often feel like there are things I can not implement because I struggle so much with web dialogs....
Chris
-
First, the bad news: simplifying the dialog part of WebDialog programming will not make the "I don't know JavaScript" blues go away. WebDialogs are programmed in two languages, and you have to speak both. The fact that there are two entirely different OO models doesn't help.
Now, good news: you don't have to know much of a language to muddle through. I know almost no Ruby, for example. (I think, "there should be one, obvious way to do it.")
Which leads to the proposal: I assume the lack of comment to the contrary implies some acceptance of my design. I'll do the JavaScript if someone will volunteer to do the Ruby.
-
@chris fullmer said:
I often feel like there are things I can not implement because I struggle so much with web dialogs....
An example or two would be very timely! What sort of dialogs are dancing at the edges of your imagination?
-
@chris fullmer said:
I would be forever indebted to whoever created such a project. I often feel like there are things I can not implement because I struggle so much with web dialogs....
Chris
Don't you think it is about time to consider setting up a separate forum for webdialogs to help consolidate all the efforts and queries that are clearly on the rise?
-
Yea, the webdialog info is very scattered.
-
@thomthom said:
Yea, the webdialog info is very scattered.
I have always preferred support to underwear.
BTW Martin maybe you missed this "Jim'll fix it" post amid the scattering.
-
@dan rathbun said:
<!-- (also known as XP style themed controls.) .HTA files always NEED this. -->
That's very interesting!
Have you done much with with HTA apps? -
Some.. they are great. You have all the power of any application. Read and write direct to files (don't have to go thru SU.)
Really, I believe HTAs are the answer to much of what ppl have been agonizing over.
(For those who don't know, an HTA stands for HyperText Application. It's really an HTML file, that has been renamed .hta; and on Windows it gets loaded by a MSIE stub called mshta.exe, which opens it in a similar way that SU does, but mshta.exe makes it a secure webdialog.)
In ruby you would open your HTA with the UI.openURL("mydlg.hta") command.My thots are:
- upgrade to Daniel J. Berger's newer better Win32::Api
...(req's swaping some parameters, he put the dll last, instead of 1st.) - also install his module for Win named pipes.
- then ruby would open a named pipe (same name as dlg) as the server
- then call the openURL "dlg.hta"
- the JS in dlg.hta would after body load open a connection to the waiting pipe as client
- two way comms from then on
- the dlg would need to put a I'm closed message in the pipe before it closes
- and the ruby script would dispose of the pipe when no longer needed
no more messin' with ghost protocol args
I've been workin' on a simple JSON module to pass things back and forth.
..but other things interrupt...
probs updating all my .NETs
probs with rubygems... so I uninstalled ruby 1.8.6
need to get 1.9.x installed with a newer rubygems - upgrade to Daniel J. Berger's newer better Win32::Api
-
hmm... you're using HTAs with Su and Ruby? Interesting, but what about Macs? A wee bit problem there.
@dan rathbun said:
Read and write direct to files (don't have to go thru SU.)
? You mean by the JS? Since SU's Ruby have no problem with file read/write. ...except that it only calls ASCII versions of the System File APIs...
-
@thomthom said:
hmm... you're using HTAs with Su and Ruby? Interesting, but what about Macs? A wee bit problem there.
@dan rathbun said:
Read and write direct to files (don't have to go thru SU.)
? You mean by the JS? Since SU's Ruby have no problem with file read/write. ...except that it only calls ASCII versions of the System File APIs...
Yes I think the Mac business restricts hta's not just for SU but for connecting SU to the rest of the world via its web dialog "portal" (can I call it that? ... sorry not a techie). But if there could be another way to read/write files the cosmetics of hta s becomes trivial - of little interest.
-
Got another 'jewel' for the WebDialog list of treasure's:
If you want to have the nice XP styled 'themed' controls (buttons, scrollbars, tabs, etc.), instead of the old ugly Win 3.x style, there's a META tag to put in the HEAD section.
This 'formally' is known as MS Common Controls ver 6 (where the old ver was 5.) These controls are housed in comctl32.dll, which shipped with XP. (Look at properties to see product ver, not file version.)here's the tag:
<!-- This tells the HTML frame to use MS Common Controls ver 6+ if available --> <!-- (also known as XP style themed controls.) .HTA files always NEED this. --> <META HTTP-EQUIV="MSThemeCompatible" CONTENT="Yes">
For more info, see Using Visual Styles with HTML Content on page: http://msdn.microsoft.com/en-us/library/ms997646.aspx#xptheming_topic11
..and BTW if ya' wonderin' why SU doesn't use ver 6 controls in their dialogs, it's because they didn't turn them 'on' (as a dependant assembly,) in the Sketchup.exe manifest. A holdover from preXP days I imagine. I'm running SU with them ON, but there are some display issues with the brown buttons on the left of the status bar (no images,) as well as few other things. [See post in Google groups, Technical Issues if interested. Have forwarded a 'bug' report to Google as well. Perhaps the next version, they'll have all the controls updated seeing as how they only support XP and higher.]
.
Advertisement