Add custom button to Toolbar/ CustomToolbar

Last post 02-15-2007, 4:05 AM by [email protected]. 3 replies.
Sort Posts: Previous Next
  •  01-31-2007, 3:03 AM 26290

    Add custom button to Toolbar/ CustomToolbar

    Hello,
     
    Could someone post an example of how to add a custom button to a Toolbar or a CustomToolbar?
    I'm using the classic asp editor and managed to add a custom button by using the CustomAddons method. But i would like to add this button to a toolbar/customtoolbar as well.
    I also found the example on customtoolbars and there was a tag:
    <item type="holder" name="insertcustombuttonhere" />
    wich indicates you could use this to add a custom button, but how do i use this .....
     
    Please help.
     
    Best regards,
    Eelco
     
  •  01-31-2007, 8:57 AM 26299 in reply to 26290

    Re: Add custom button to Toolbar/ CustomToolbar

    Eelco,
     
    "holder" is not supported in the current version.
     
    Here is the syntax to add new button or dialog:
     
    editor.CustomAddons = "<img title=""Underline"" class=""CuteEditorButton"" onclick=""ShowMyDialog(obj_Editor1)"" type=""btn"" src='CuteEditor_Files/images/emrainbow.gif' hspace=2 border=0 />"
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  01-31-2007, 5:32 PM 26319 in reply to 26299

    Re: Add custom button to Toolbar/ CustomToolbar

    Adam,

    I know this code, but this will add the custom button as a seperate button to the toolbar. Behind the last toolbar defined in the configuration file.
    Is it not possible to add a custom button to an existing toolbar or a customtoolbar?

    Eelco

  •  02-15-2007, 4:05 AM 26724 in reply to 26319

    Re: Add custom button to Toolbar/ CustomToolbar

    Hello Adam,

    I have rewritten your include_CuteEditor.asp file, so i can simple add custombuttons to my configuration file!
    Below an example: First configuration file:
    <item type="linebreak" />
    <item type="g_start" />
    <item type="custombutton" name="link" command="StyleIT_MaakLink('strStyleITContent');" imagename="link" />   
    <item type="image" name="Unlink" />
    <item type="custombutton" name="afbeelding" command="StyleIT_MaakAfbeeldingEenvoudig(500, 'ja', 150, 2,'strStyleITContent');" imagename="image" />   
    <item type="separator" />
    <item type="g_end" />

    And the code, i have changed the function: GetToolbarFromItemList(d_list)
        Public function GetToolbarFromItemList(d_list)
            dim scriptname,cfgfilename,doc,temp
            dim node,selectednode,optionnodelist,errobj
            dim selectednodes,s
            s=""
                   
            cfgfilename = Server.MapPath(GetURL("Configuration/AutoConfigure/full.config"))
           
            ' Create an object to hold the XML
            set doc = server.CreateObject("Microsoft.XMLDOM")

            ' For ASP, wait until the XML is all ready before continuing
            doc.async = False

            ' Load the XML file or return an error message and stop the script
            if not Doc.Load(cfgfilename) then
                Response.Write "Failed to load the Configure file.<br>"
                Response.End
            end if

            ' Make sure that the interpreter knows that we are using XPath as our selection language
            doc.setProperty "SelectionLanguage", "XPath"
       
            'set selectednode= doc.selectSingleNode("/toolbars")
            Dim Nodes
            set Nodes = doc.DocumentElement.selectNodes("//toolbars/*")
           
            Dim ToolbarStrings
            Dim i
                   
            If    BrowserType="Gecko" Then
                d_list = d_list & ",zoom"
            End If
           
            If    BrowserType="Safari" Then       
                d_list = d_list & ",zoom,find,tofullpage,fromfullpage,linktree,inserttemplate,modifytable,insertrowtop,insertrowbottom,insertcolumnleft,insertcolumnright,deletecell,deleterow,deletecolumn,insertcell,editrow,editcell"
                d_list = d_list & ",mergeright,mergebottom,horsplitcell,versplitcell,blockdirltr,blockdirrtl,insertorderedlist,insertunorderedlist,indent,outdent,imagemap,insertanchor,documentpropertypage,absoluteposition"
                d_list = d_list & ",bringforward,bringbackward,cssclass,cssstyle"
            End If
           
            ToolbarStrings = Split(s_templateitemlist,",")
            For i = 0 to Ubound(Split(s_templateitemlist,","))
                dim itemname           
                itemname = Trim(ToolbarStrings(i))
               
                dim disable_toolbarstrings, j,found
                found = false
                disable_toolbarstrings = Split(d_list,",")
                for j = 0 to Ubound(disable_toolbarstrings)                    
                    if lcase(itemname) = lcase(trim(disable_toolbarstrings(j))) then
                        found = true
                        Exit for                   
                    end if
                next
                if found = false then
                Select Case lcase(itemname)
                    case "g_start":
                        s =  s &     AddToolbarGroupStart
                    case "g_end":
                        s =  s &     AddToolbarGroupEnd
                    case "separator":
                        s =  s &     AddToolbarSeparator
                    case "linebreak":
                        s =  s &     AddToolbarLineBreak
                    case "table":
                '        s =  s &     AddToolbarLineBreak
                    case "forecolor":
                        s =  s &     AddToolbarForeColor
                    case "backcolor":
                        s =  s &     AddToolbarBackColor
                    case "dropdown":
                '        s =  s &     AddToolbarLineBreak
                    case "holder":
                '        s =  s &     AddToolbarLineBreak

                    Case else
                        Dim objNode,objType,objName,objImgName,objVisible,v, objCommand
                        For Each objNode in Nodes
                            With objNode.Attributes   
                              set objType = .GetNamedItem("type")
                                set objName = .GetNamedItem("name")
                                set objVisible = .GetNamedItem("Visible")   
                                v = "true"                                                   
                                If not objVisible is nothing  then
                                    v = objVisible.Text
                                End If
                                If not objName is nothing AND lcase(v) <> "false" then   
                                    if lcase(objName.Text) = lcase(itemname) then                                   
                                        If lcase(objType.Text) = "image" then
                                            dim n,t                           
                                            n = objName.Text   
                                            set objImgName = .GetNamedItem("imagename")
                                            If not objImgName is nothing  then
                                                t = .GetNamedItem("imagename").Text
                                            else
                                                t = n                               
                                            End If    
                                            s =  s & AddToolbarItem(n,ProcessThemeWebPath(t & ".gif"), n,20,20)   
                                       
                                        ElseIf (LCase(objType.Text) = "custombutton") Then
                                           
                                            Dim strTitle,strImageURL                           
                                            n = objName.Text   
                                            Set objImgName = .GetNamedItem("imagename")
                                            If (Not objImgName Is Nothing) Then
                                                strImageURL = .GetNamedItem("imagename").Text
                                            Else
                                                strImageURL = strTitle
                                            End If                                            
                                            Set objCommand = .GetNamedItem("command")   
                                            s = s & AddCustomToolbarItem(objCommand.Text, ProcessThemeWebPath(strImageURL & ".gif"), strTitle)
                                        Else
                                            Dim objCmd
                                            set objCmd = .GetNamedItem("command")
                                            s =  s & AddToolbarDropDown(objName.Text,objCmd.Text)
                                        End If

                                    end if   
                                End if   
                            End With                       
                        Next                                       
                End Select
                end if
            Next   
            GetToolbarFromItemList = s
        End function

    I have added de following function:
    Public Function AddCustomToolbarItem(strCommand, strImageURL, strTitle)
     AddCustomToolbarItem = "<img title="""&G_Str(strTitle)&""" class=""CuteEditorButton"" onclick="""&strCommand&""" src='"&strImageURL&"' border=0 />"
    End Function

    Possible you could use this, to fix some incompatibility .........

View as RSS news feed in XML