Author Topic: Is there a way to add a text box to a custom toolbar  (Read 2962 times)

pmsteinm

  • Community Member
  • Posts: 78
  • Hero Points: 0
Is there a way to add a text box to a custom toolbar
« on: October 02, 2012, 08:52:42 pm »
I'd like to have a text box on a toolbar that I can type some text into and have it either save as a variable or allow me to call a macro with the value of the text as the macro argument.

Is this possible, and if so, how?

Graeme

  • Senior Community Member
  • Posts: 2158
  • Hero Points: 268
Re: Is there a way to add a text box to a custom toolbar
« Reply #1 on: October 03, 2012, 07:53:55 pm »
Yep, it's easy but I don't have time to give any details right now.  If no-one else does, I'll explain in a couple of days if you haven't figured it out.  In the meantime, look up textboxdialog in the help and see if that will do what you want - it has an example of how to use it.

Graeme

  • Senior Community Member
  • Posts: 2158
  • Hero Points: 268
Re: Is there a way to add a text box to a custom toolbar
« Reply #2 on: October 05, 2012, 08:54:15 am »
To make a toolbar with an edit box

In the Macro menu, select "new form"
In the properties dialog, change name to e.g. "mytoolbarform" and caption to mytoolbar.  Set border-style to BDS_SIZABLE and set tool_window to true.
In the properties dialog, click on the icon for a "text box", then click and drag on your form to create a textbox of the size you want.  In the properties dialog, set the font-size to the size you want.  Leave the ListCompletions property true for now.
To create an event handler for the text box, double click in the textbox on the form and select "key or mouse event", then press the ENTER key.  Type a name for the source file where you will put the event handler code e.g. mytoolbar-form.e, click ok and a stub event handler for the pressing of ENTER in the textbox will open.
Code: [Select]
void ctltext1.'ENTER'()
{
   _message_box(p_text);
}
On the macro menu, click "load module" to load the form.
On the the form designer mytoolbar form, right click and select save, then close the form designer.

In the main slickedit window, right click on any toolbar and select toolbars -> customize.  On the toolbars tab, click New.  Enter mytoolbar for the name, click advanced and enter mytoolbar for the form name and click ok.  Click the apply button in the options dialog and click ok.

Your toolbar will probably be visible now, if not click menu view -> toolbars and check mytoolbar.
Type some text in the toolbar and press enter.  You should be able to dock your toolbar anywhere you want.

pmsteinm

  • Community Member
  • Posts: 78
  • Hero Points: 0
Re: Is there a way to add a text box to a custom toolbar
« Reply #3 on: October 05, 2012, 07:45:52 pm »
Awesome.  That did exactly what I want.  Thanks!