|
|
This FAQ complements Thinlet's official documentation and aims to provide you with information that is not included in the official documentation for whatever reason. If you just started with the Thinlet XML UI Language (XUL) Toolkit, please check out Thinlet's official documentation and samples first. I invite you to share your insights, comments, suggestions, or corrections. Please send them to the Thinlet Developers Group or send a private email to gerald@vamphq.com (Gerald Bauer). The Thinlet FAQ is a living, growing list of answers, not just a publish-and-forget-it static dead-tree booklet, help to improve it.
Q: How can I make text append itself to the bottom of a textarea widget and how can I autoscroll text upwards as new text comes in?
A:
String text = getString(textarea, "text") + "\nappended line"; setString(textarea, "text", text); setInteger(textarea, "start", text.length()); setInteger(textarea, "end", text.length());
Q: How do I set the status of a checkbox?
A:
setBoolean( find("nameofcheckbox"), "selected", true ); setBoolean( find("nameofcheckbox"), "selected", false );
Q: How do I use java.awt.FileDialog
with Thinlet?
A:
Container frame = this; while (!(frame instanceof Frame)) { frame = frame.getParent(); } java.awt.FileDialog filedialog = new java.awt.FileDialog( (Frame)frame, "Saveg database...", FileDialog.SAVE); filedialog.show(); File fileSelected = new File( filedialog.getDirectory(), filedialog.getFile() );
Q: How do I dynamically add nodes to a tree?
A: Assuming your tree is defined: <tree name="ParentTree"></tree>
:
then you can perform:
Object root = find("ParentTree"); Object node = create("node"); setString(node,"text","Node label"); add(root,node);
Q: Can I script Thinlet using Groovy?
A: Yes, you can. Norbert Barbosa's has created a Thinlet extension called Scriptable Thinlet that lets you script Thinlets using half a dozen scripting languages including Groovy. See http://sjobic.club.fr/thinlet/scriptablethinlet for details.
Q: Can I script Thinlet using Pnuts?
A: The Pnuts scripting language lead Toyokazu Tomatsu has added Thinlet support to Pnuts and writes in the blog story titled "Pnuts meets Thinlet":
Added Thinlet module:
Here is a sample code:
import javax.swing.* use("thinlet") parseThinlet("calculator.xml", f = JFrame()) function calculate(n1, n2, r){ r.text = string(int(n1) + int(n2)) } f.pack() f.show()
Source: http://jroller.com/page/tomatsu/20041106#pnuts_meets_thinlet
You can find out more about Pnuts and Thinlet online @ http://pnuts.org/snapshot/latest/extensions/thinlet/doc
Please send comments on our web pages to our public xul-talk mailinglist or to a member of our web team. | Copyright © 2003, 2004, 2005 Open XUL Alliance |