CreateCommand() public method

public CreateCommand ( string cmdName, TclCmdProc proc ) : TclCmdToken
cmdName string
proc TclCmdProc
return TclCmdToken
Exemplo n.º 1
0
        void InitProc(TclInterp interp)
        {

            /*
             * Initialize TCL - basically this function runs the init.tcl file which 
             * should be in your path environment variable.
             */
            interp.TclInit();
    
            /*
             * Initialize the TK libs - basically loads all of the .tcl files that define
             * the widgets - these should be in the tcl\lib path (which should also be in
             * your path environment variable).
             */
            interp.TkInit();

            /*
             * Evaluate a script - this creates a button, called .b with a label "Hello, World!".
             * When the button is pressed it writes "Hello, world" to the console.
             */
            
            //Create the main window.
            interp.Eval("button .b -text {Hello, World!} -command {doIt}; pack .b");
            interp.CreateCommand("doIt", new TclCmdProc(doItProc));
        }
Exemplo n.º 2
0
        void InitProc(TclInterp interp)
        {

            /*
             * Initialize TCL - basically this function runs the init.tcl file which 
             * should be in your path environment variable.
             */
            interp.TclInit();
    
            /*
             * Initialize the TK libs - basically loads all of the .tcl files that define
             * the widgets - these should be in the tcl\lib path (which should also be in
             * your path environment variable).
             */
            interp.TkInit();

            /*
             * Evaluate a script - this creates a button, called .b with a label "Hello, World!".
             * When the button is pressed it writes "Hello, world" to the console.
             */
            
            //Setup the main window.
            interp.Eval("wm title . \"C# Notepad Using TCL - Untitled\"");
            
            //Create a text editor with a scrollbar - and pack it so that it always fills the 
            //available space in the window.
            interp.Eval("text .text -yscrollcommand \".scroll set\" -setgrid true -font {Courier 10}");
            interp.Eval("scrollbar .scroll -command \".text yview\"");
            interp.Eval("pack .scroll -side right -fill y");
            interp.Eval("pack .text -expand yes -fill both");

            //Setup the initial menus.
            interp.Eval("menu .menu -tearoff 0");
            interp.Eval("menu .menu.file -tearoff 0");
            interp.Eval("menu .menu.search -tearoff 0");

            //Add items to the 'file' menu and add it to the menubar.
            interp.Eval(".menu add cascade -label {File} -menu .menu.file");
            interp.Eval(".menu add cascade -label {Search} -menu .menu.search");

            interp.Eval(".menu.file add command -label {New} -command {cmdNew}");
            interp.Eval(".menu.file add command -label {Open...} -command {cmdOpen}");
            interp.Eval(".menu.file add command -label {Save...} -command {cmdSave}");
            interp.Eval(".menu.file add command -label {Save As...} -command {cmdSaveAs}");
            interp.Eval(".menu.file add separator");
            interp.Eval(".menu.file add command -label {Exit} -command {cmdExit}");
            
            interp.Eval(".menu.search add command -label {Highlight} -command {cmdHighlight}");

            //Enable menus for the root window.
            interp.Eval(". configure -menu .menu");

            //Setup the menu callbacks.
            interp.CreateCommand("cmdNew", new TclCmdProc(cmdNew));
            interp.CreateCommand("cmdOpen", new TclCmdProc(cmdOpen));
            interp.CreateCommand("cmdSave", new TclCmdProc(cmdSave));
            interp.CreateCommand("cmdSaveAs", new TclCmdProc(cmdSaveAs));
            interp.CreateCommand("cmdExit", new TclCmdProc(cmdExit));
            interp.CreateCommand("cmdHighlight", new TclCmdProc(cmdHighlight));
        }