Options menu in cool term

If you have specific questions or problems with any of my Freeware applications, post them here.
Post Reply
ernieb
Posts: 1
Joined: Sun Oct 21, 2012 9:04 am

Options menu in cool term

Post by ernieb »

Roger, I use cool term a lot to test stuff on Serial ports. Thank you for a useful tool.

I am writing a program and need a prefs menu like you have but have not been able to figure it out. Could you give me some guidance on how to go about setting up the window and if it is not standard how you go about adding controls in the window.

I am using a Mac and I have found the prefsmenuitem but the documentation on how to use it is not too clear.

Thx
Ernie
User avatar
roger
Site Admin
Posts: 434
Joined: Fri Apr 24, 2009 12:41 am
Contact:

Re: Options menu in cool term

Post by roger »

Hi,

I assume you are using Xojo or REALBasic for you application?

Anyways, the connection options window is a regular window. If you're not sure how to add controls to a window, then I recommend completing the tutorial before continuing. Looking at some of the examples that come with Xojo is also helpful.
Ok, back the preferences window. The white box on the left is a ListBox. When you place the listbox, use the "InitialValue" property to enter the different items you want to show in the list. Add a Cancel and Ok button to the bottom right corner. Then you will need to add Canvases (all of them must be the same size) to the window, one for each list item. The first one needs to be placed on the window, to the right of the List Box and above the buttons. Place the other ones outside of the window. Make sure they are next to each other and do not overlap. Place all your controls to adjust your settings (textfields, labels, radio buttons, etc) onto the different canvases.
Add code to the "Open" event handler of your preferences to move all the canvases to the same location on the window, where you placed the first canvas. Use the "Top" and "Left" properties of Canvas to set the position of the canvases to the same coordinates. Set the "Visible" property of all the canvases, except for the first one, to "false". When the app runs and the preferences window opens, all the canvases will be in the same location, but only the first one will be visible.
Set the name of the Canvases to be the same and create a control array with the canvases so that you can access them using the index. E.g. name them "cvSettings" and set the index of the first canvas to 0, the second one to 1, etc. Then implement the "Change" event handler of the ListBox so that it makes the current canvas invisible and makes the Canvas that corresponds to the currently selected item in the list visible. I.e. your Change event handler will then look something like this:

Code: Select all

Sub Change()
  dim i as integer = me.ListIndex
  if not (cvSettings(i) is nil) then
    cvSettings(CurrentCanvas).Visible = False
    CurrentCanvas = i
    cvSettings(CurrentCanvas).Visible = True
    self.Refresh
  end if
End Sub
In order for this to work you need to add a property "CurrentCanvas" to the window.
Post Reply