Go Back   SmartClient Forums > Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 19th Aug 2012, 10:16
ctanked ctanked is offline
Registered Developer
 
Join Date: Dec 2011
Posts: 26
Default ace editor integration

Hello,

we are using 8.2.

I am trying to integrate the Ace Editor into smartclient and I am having some issues. Has anyone tried to integrate it before?

http://ace.ajax.org/

Its tagged to a div element and when I try to display it won't draw correctly (seems like it can't determine its size). I have tried overriding getInnerHTML on a canvas and returning the div with the correct id and I can see it does find the element and attaches the editor but the size of the editor is not set.

Simple code that will display the ace editor:
Code:
<body>
<div id="aceeditor"></div>
<script>
    var container = document.getElementById("aceeditor");
    var aceeditor = ace.edit("aceeditor");
    aceeditor.getSession().setMode("ace/mode/javascript");
    aceeditor.getSession().setValue("test code\n");
</script>
</body>
An example of trying to integrate it:
Code:
<body>
<script>
    isc.defineClass("DevEditor", "Canvas");
    isc.DevEditor.addProperties({
        title: "Test",
        height: "100%",
        width: "100%",
        getInnerHTML : function ()
        {
            return "<div id=\"aceeditor\"></div>";
        }
    });
    var aLayout = isc.VLayout.create({width: "100%", height: "100%"});
    var ldev = isc.SamDevEditor.create();
    aLayout.addMember(ldev);
    isc.Page.setEvent("load", function()
    {
        var container = document.getElementById("aceeditor");
        var aceeditor = ace.edit("aceeditor");
        aceeditor.getSession().setMode("ace/mode/javascript");
        aceeditor.getSession().setValue("test code\n");
    });
    aLayout.draw();
</script>
</body>
What I see in the debugger is the size of the editor is 0. Anyone have experience with Ace editor or any tips on what I am doing wrong?

Thanks!
Reply With Quote
  #2  
Old 20th Aug 2012, 11:29
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,561
Default

With this particular code, the problem is the attempt to create() a SamDevEditor, when you gave the class the name "DevEditor". Was this just a transcription error..?
Reply With Quote
  #3  
Old 20th Aug 2012, 11:32
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,561
Default

Assuming it is a transcription error, you have a further issue - you're creating a DIV inside a 100% sized Canvas, but the DIV itself has no size setting that would cause it to fill the surround Canvas. So it's going to be minimum height.

See also the new docs on DOM-level integration added in 3.1, but which apply to older versions too.
Reply With Quote
  #4  
Old 20th Aug 2012, 17:59
ctanked ctanked is offline
Registered Developer
 
Join Date: Dec 2011
Posts: 26
Default

yes, it was a transcription error...

Thanks for the help!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved