Ymacs without menu and not wrapped in a dialog?

29 views
Skip to first unread message

Joe

unread,
Oct 28, 2010, 5:28:16 AM10/28/10
to Ymacs - AJAX code editor
Hi,

I'd like to have ymacs run without the menu. I tried this:

var xml = new Ymacs_Buffer({ name: "index.html" });
var ymacs = window.ymacs = new Ymacs({ buffers: [xml] });
ymacs.setColorTheme([ "dark", "y" ]);

var layout = new DlLayout({});
layout.packWidget(ymacs, { pos: "top", fill: "*" });
layout.display(false);

But ymacs does not appear.
any pointers would be appreciated.

Mihai Călin Bazon

unread,
Oct 28, 2010, 10:37:54 AM10/28/10
to ym...@googlegroups.com
Where do you want it to appear?  The layout widget is not added anywhere, so that's why it doesn't show up.  If you wanted to add it inside another widget, you can specify the parent property.  One take, if you want to go "full-screen", is to use a DlDesktop container.  That's described here: http://www.dynarchlib.com/dl/index.html#api://DlDesktop.xml

Otherwise you can add the layout widget to the container of your choice, if you have a reference to it, something like this:

    your_element.appendChild(layout.getElement());

Note that you should set a size for your layout, i.e. layout.setSize({ x: 500, y: 400 }) — do this *after* inserting it into the DOM.  And remove layout.display(false), as that hides it. ;-)

Cheers,
-Mihai

PS: if there's nothing else than the Ymacs widget, you don't need a Layout container, you can put the ymacs element itself into some other element, same as described above.  And you still need to give it a size.


--
www.ymacs.com - AJAX code editor



--
Mihai Bazon,
http://mihai.bazon.net/blog

Joseph McDonald

unread,
Oct 28, 2010, 2:46:22 PM10/28/10
to ym...@googlegroups.com
Thanks Mihai,

I want it to take up the entire window, and if the window resizes, to
resize automagically.
This is closer:


var xml = new Ymacs_Buffer({ name: "index.html" });
var ymacs = window.ymacs = new Ymacs({ buffers: [xml] });
ymacs.setColorTheme([ "dark", "y" ]);

var e = document.getElementById('ed');
e.appendChild(ymacs.getElement());
ymacs.setSize({ x: "100%", y: "100%" })

but it appears it doesn't like "%"'s as it makes a 100x100 ymacs.
thanks,
-joe

2010/10/28 Mihai Călin Bazon <mihai...@gmail.com>:

Mihai Călin Bazon

unread,
Oct 28, 2010, 2:50:55 PM10/28/10
to ym...@googlegroups.com
Go for DlDesktop then, that is:
var desktop = new DlDesktop({});
desktop
.fullScreen();
...
var ymacs = new Ymacs({ parent: desktop, buffers: [xml] });

Hope this helps.

-Mihai

Joseph McDonald

unread,
Oct 28, 2010, 8:21:08 PM10/28/10
to ym...@googlegroups.com
So close!
I have

var desktop = new DlDesktop({});
desktop.fullScreen();

var xml = new Ymacs_Buffer({ name: "index.html" });
xml.setCode("<div>hello world</div>")
var ymacs = window.ymacs = new Ymacs({ parent: desktop , fillParent:
true, buffers: [xml] });


ymacs.setColorTheme([ "dark", "y" ]);

the ymacs widget is just 1 line tall though. If I resize the window,
it resizes to take up the entire window which is what I'm looking for.
but it won't initialize that way.

Mihai Călin Bazon

unread,
Oct 29, 2010, 1:45:08 AM10/29/10
to ym...@googlegroups.com
Oh, I see..  Try this:

    desktop.callHooks("onResize");

That should force it to re-layout.

Cheers,
-Mihai

Joseph McDonald

unread,
Oct 29, 2010, 10:40:06 AM10/29/10
to ym...@googlegroups.com
That did it! Thanks so much Mihai!
Reply all
Reply to author
Forward
0 new messages