Some news update on Mac: Trolltech is supporting the Cocoa API through Qt in the future. Read more on http://trolltech.com/company/newsroom/announcements/press.2008-03-03.5380825926
KBasic's look and feel is equally on every platform, but there is one exception. The menubar designer is not present on Mac, because of the limitation of the menubar provided by Qt on Mac. On Mac the Qt menubar is actually a native Mac OS X menubar and is not created by Qt itself, therefore there is no feature of having two menubars at once on screen. But this feature is needed for KBasic's menubar designer and works well on Windows and Linux.
Therefore, if you would like to create a custom menubar, you have to write it in plain text, what your menubar should look alike. When you click on new menubar on Mac a plain text editor appears in which you may enter the needed information. Don't worry it is really easy to create such a file and it is worth it!
By the way, menubar files created with the menubar designer of KBasic on Windows and Linux works on Mac as well.
The file's format looks like the following
Comments are not allowed, so do not use REM or '.
There are no properties for menubars yet, but you need to write two lines, which encloses the menubaritems.
Begin MenuBar * ' place your menubaritems here End MenuBar
Write the following lines for every menu and change NAME to the right one.
Begin Menu NAME ' place your properties here End
Layout properties
Describes if this menubaritem is a main menubaritem on the bar (ParentControl = ””) or a child menubaritem, then ParentControl contains the name of the parent menubaritem.
Together with ParentControl, ParentIndex describes the position of this menubaritem in the list of the child menubaritems of ParentControl. ParentIndex starts with 0 then 1, 2, 3 and so on.
Example
DO NOT COPY THIS EXAMPLE, BECAUSE IT CONTAINS SOME COMMENTS, WHICH ARE NOT ALLOWED Begin Menu MenuBarItem0 Caption = "Edit" Enabled = True ParentIndex = 0 ' THIS IS THE FIRST MENUBARITEM, because there is no ParentControl End '(means ParentControl = ""), it is placed on the menubar on top. Begin Menu MenuBarItem1 Caption = "File" Enabled = True ParentControl = "MenuBarItem0" ' THIS IS THE FIRST MENUBARITEM, of the menu of MenuBarItem0 declared above ParentIndex = 0 ' set to position 0 End
Working like normal menubaritems, but visually create a new menu, when the user enters this menubaritem.
Write ChildMenu instead of Menu as menubartype.
Begin ChildMenu MenuBarItem4 Caption = "Custom ChildMenu" Enabled = True ParentControl = "MenuBarItem1" ParentIndex = 1 End
Write MenuItem instead of Menu as menubartype.
Begin MenuItem MenuBarItem4 Caption = "Custom menu entry" Enabled = True ParentControl = "MenuBarItem1" ParentIndex = 1 End
Data properties
Add your code lines after the line:
End MenuBar
Adding event procedures is really simply. Just write a new sub with the name of the menuitem and “_OnEvent()”. Add your code inside and you are done.
Sub NAME_OnEvent() ' your code here End Sub Sub MenuBarItem2_OnEvent() ' your code here End Sub
Add two more functions for the about box and help/contents dialog.
Sub About_OnEvent() ' your code here End Sub Sub Contents_OnEvent() ' your code here End Sub
Begin MenuBar * Begin Menu MenuBarItem0 Caption = "Edit" Enabled = True ParentIndex = 1 End Begin Menu MenuBarItem1 Caption = "File" Enabled = True ParentIndex = 0 End Begin MenuItem MenuBarItem2 Caption = "CustomItem" Enabled = True ParentControl = "MenuBarItem0" ParentIndex = 0 End Begin MenuItem MenuBarItem3 Caption = "More" Enabled = True ParentControl = "MenuBarItem0" ParentIndex = 1 End Begin ChildMenu MenuBarItem4 Caption = "Custom ChildMenu" Enabled = True ParentControl = "MenuBarItem1" ParentIndex = 1 End Begin MenuItem MenuBarItem5 Caption = "Close" Enabled = True ParentControl = "MenuBarItem1" ParentIndex = 2 End Begin MenuItem MenuBarItem10 Caption = "Print" Enabled = True ParentControl = "MenuBarItem4" ParentIndex = 1 End Begin MenuItem MenuBarItem11 Caption = "Hide" Enabled = True ParentControl = "MenuBarItem4" ParentIndex = 2 End Begin MenuItem MenuBarItem12 Caption = "Open" Enabled = True ParentControl = "MenuBarItem1" ParentIndex = 0 End End MenuBar Sub About_OnEvent() Print "you selected About" End Sub Sub Contents_OnEvent() Print "you selected Contents" End Sub Sub MenuBarItem2_OnEvent() Print "you selected CustomItem" End Sub Sub MenuBarItem3_OnEvent() Print "you selected More" End Sub Sub MenuBarItem12_OnEvent() Print "you selected Open" End Sub Sub MenuBarItem5_OnEvent() Print "you selected Close" End Sub Sub MenuBarItem10_OnEvent() Print "you selected Print" End Sub Sub MenuBarItem11_OnEvent() Print "you selected Hide" End Sub