PDA

View Full Version : When can you use the XMLUI Object?


abeall
02-21-2007, 07:00 PM
From the docs:

The XMLUI methods can be used in callbacks, such as oncommand handlers in buttons.

However, after reading through the docs and just trying things, I haven't found anywhere else it can be used. Particularly, I would like to respond to a user selection an item from a menulist, or in response to a checkbox. I'd also like to trigger some JS which adjusts the dialog when it first launches. Can any of this be done, or can JS and the XMLUI object only be used in response to the user clicking a button?

mooska
02-21-2007, 07:16 PM
Yeah, that is a prob. Help, and online docs never speak about anything more then button callback. There are some like onsetfocus and oncommand, oncreate, but I havent found anything more then that :)

If youll find anything about it, some docs or self experience, please share it, Ill be greatfull :)

abeall
02-21-2007, 07:29 PM
Well, I think I just found something that might help:
http://www.xulplanet.com/references/elemref/ref_EventHandlers.html

I haven't tried all the events, but a few of the ones I particularly need seem to work!

However, where does the .jsfl go which should be executed? For instance, I have:
<button id='bla' label='say bla' oncommand='sayBlah'/>

What and where is "sayBlah"? Is it a function defined in the calling .jsfl? That didn't seem to work. Is it a seperate file, sayBlah.jsfl, in the same directory? That didn't work...

abeall
02-21-2007, 07:59 PM
I see... it is literal JS. So it should be something like:
<button id='bla' label='say bla' oncommand='fl.trace("blah")'/>

Is there any way to define JS functions in the XML? Like the <script> tag?

mooska
02-21-2007, 07:59 PM
just plase js code in it
oncommand='fl.trace("hello")'

abeall
02-21-2007, 08:02 PM
What if I have a lot of code? Is there a way to define a function and just call it inside the event?

krayzeebean
02-21-2007, 11:23 PM
I think you can just put it in a seperate jsfl file and call that file, or a function within the file. I don't remember the jfsl code for that offhand but it should be in the docs.

linakutak
03-12-2007, 02:36 AM
yes.. you can define JS functions in the XML by using <script> tag.
Place it above </dialog> tag. But no 'for' looping coding... it is an error.
<?xml version="1.0"?>
<dialog id="Preamble" title="Preamble" buttons="accept, cancel">
<button id="worldBtn" label="world" oncreate = 'init()'/>
<textbox id="tb" >
<script>
function init(){
fl.xmlui.set("tb", "Development");
}
</script>
</dialog>

abeall
03-17-2007, 05:48 PM
Good to know, both, thanks.