Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Sep 21, 2019 2:28 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 4:16 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
I rarely use menu bars in my programs, because (at least on Windows) you can use only System 0 as the font and on my monitor that is too small for me to read comfortably. But for what I'm working on now, I have to use that kind of menu and I've run into a problem, probably a simple question for most people but not simple for me, since (as I said) I rarely use menu bars in my programs.

I want to add a separator bar to my menu. I add it, and you can see that I've added it, but it disappears when the program is run, even I include this code before I access the menu.

mnuSeparator1.Enabled = True
mnuSeparator1.Visible = True

whereas regular menu items show up and do what they are supposed to do.

Now, separator bars don't do anything, so I suppose in a sense it isn't really important that they don't show up, but I'm not comfortable about that. (For one thing, I have a vague memory that I ran across a similar problem years ago but with a regular menu item rather than a separator line. Unfortunately, I can't find that question and answer.)

Any ideas as to what I may be doing wrong? (And I won't get upset if you tell me that I should have remembered such a simple thing.)

Thanks in advance for your thoughts.

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 9:43 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
(Unhelpful, I know, but this has sat unanswered all day...)
They work for me... nothing special required.
I just add a menu item at design time, and set it to have a hypen as a caption -
What OS are you on, and what version of RB?

Can you export the menu bar as XML and post it here in response? I'll try it on my setup.
Might you have two menus: showing different ones according to which window is open?


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 12:43 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
New MenuItem(MenuItem.TextSeparator)

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 5:30 pm 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
kermit and DaveS,

Thanks for the posts.

I'll try to answer kermit's questions (if needed) in a later post, but I have a simpler question that may help to explain better the background of the problem.

Here's the situation. When the program is first run, only two items show up on the FIle menu:

Open XML
Exit

Both work properly. (I'll get to the simpler question in a moment.) If you choose Open XML, the program opens an XML file AND (behind the scenes) expands the File menu to include these items:

Open XML
Save XML
Save Source
Save Results
Print XML
Print Source
Print Results
Exit

All of these also work properly. And I know where my code is to expand my File menu. (See below.)

Now, here's my simpler question (probably embarrassingly simple): where did I set up the first version of my FIle menu? If I go to look at MenuBar1, the list shows all the menu items, so where did I tell the program to show only Open XML and Exit the first time around? (I think that part of my program may have been written years ago.)

I updated MenuBar1 to show these options:

Open XML
separator 1
Save XML
Save Source
Save Results
separator 2
Print XML
Print Source
Print Results
separator 3
Exit

Except for the separators, all of these items show up properly on the second version of the File menu when the program runs and they all do what they are supposed to do. At the end of the showing of the first version of the FIle menu is where I put the code to prepare the second showing of the File menu:

mnuSeparator3.Enabled = True
mnuSeparator2.Enabled = True
mnuSeparator1.Enabled = True
mnuSeparator3.Visible = True
mnuSeparator2.Visible = True
mnuSeparator1.Visible = True
mnuQuit.Visible = True
mnuPrintResults.Visible = True
mnuPrintXML.Visible = True
mnuPrintSource.Visible = True
mnuSaveXML.Visible = True
mnuSaveResults.Visible = True
mnuSaveSource.Visible = True
mnuOpenXML.Visible = True

Everything works properly (except for the separators), and I think that all of the methods are properly defined (e.g., mnuSaveSource simply contains SaveSource and SaveSource simply tells RB the specifics of how to Save the Source), BUT (this should be very simple) I can't figure out how RB knows the first time around what to include and what not to include in the File menu.

What am I missing?

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 6:13 pm 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
Dave S,

Been there, done that (if I understand you correctly) I don't think I explained myself very well in my first post. I'm hoping that my latest should be a bit clearer.

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 6:20 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Not sure if this is a platform problem or not...
But I did this under OSX using RS2012r2.1

Made MenuBar1

added 3 items

Menu Item : menu_OPENXML - caption "Open XML"
Menu Sep : mnu_SEP1
Menu Item : menu_SAVEXML - caption "Save XML"

In APP.OPEN I put

mnuSep1.Visible=false
menu_SaveXML.visible=false


created TWO Menu Handlers

FUNCTION Menu_OPENXML as boolean
msgbox "Open XML..and toggle SAVE XML"
mnuSep1.Visible=not mnuSep1.Visible
menu_SaveXML.visible=not menu_SaveXML.Visible
Return True
END FUNCTION

FUNCTION menu_SAVEXML as boolean
msgbox "SAVE XML"
Return True
END FUNCTION


Every time I selected the OPEN XML menu item... the Sep and Save XML menuitem toggled visible to invisible and back

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 9:39 pm 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
I haven't had opportunity yet to read Dave's latest posting yet,but I wanted to correct something I said before which was just plain WRONG. Yes, the first display of the File menu had only two items, Open XML and Exit, and they both worked, and, yes, the second display of the FIle menu has lots of items and they all seem to work, BUT when you click on File a third time, NOTHIING HAPPENS! The word File continues to be shown, but nothing appears beneath it -- no subitems are shown <sigh>.

I don't see a consistent pattern yet, but what happens when you click on File seems to be related to what tab TabPanel1 is set on! I hadn't even seen that the TabPanel was involved. It looks like there is only one top menu bar, but there could conceivably be as many as four <sigh>.

Dave commented on his experimentation that "Every time [he] selected the OPEN XML menu item... the Sep and Save XML menu item toggled visible to invisible and back." That may fit in with the different versions that appear. I fully admit that I'm totally out of my element here. What I thought was a simple question turned out to be anything but....

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 9:56 pm 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
In case anyone wants to look at the latest version of my program (and I don't blame you if you don't), you'll find it here:

http://traver.org/ch/ch109,rbp

http://traver.org/ch/ch109,xml

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 10:04 pm 
Offline
User avatar

Joined: Thu Sep 10, 2009 2:50 am
Posts: 418
Location: Santa Cruz, CA, USA
barrytraver wrote:
If you choose Open XML, the program opens an XML file AND (behind the scenes) expands the File menu to include these items:

Open XML
Save XML
Save Source
Save Results
Print XML
Print Source
Print Results
Exit


Why expand those items in? I'd start with the full list and enable/disable Saves and Prints as appropriate.

Assuming when you open a file you store a reference to it, then implement the EnableMenuItems event like this...
dim fileIsOpened As boolean = (theFileReference <> nil)

FileSaveXML.Enabled = fileIsOpened
FileSaveSource.Enabled = fileIsOpened
FileSaveResults.Enabled = fileIsOpened
//...etc


Oh, and for those menuitems turn AutoEnable Off.


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Wed May 15, 2013 11:57 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Barry, you're calling ZapFileMenu in certain code paths, and then not calling anything that makes menu items visible. You've got code that sets the visibility of the menu items scattered all over. I'd recommend putting it all into one place where you set the visibility based on the current state of the program - xml loaded or not, xml modified, etc. Then it's a matter of, Did I call the menu setup or not? Another option would be to make a separate method for each "menu state", where you set all the items visible or not. Then you have a single routine to call at any given point in the program.

Bottom line, don't depend on setting all the items invisible at the start of a routine and then setting just the right ones visible later on. It's too easy to miss setting them back to visible, as you are currently experiencing.


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Thu May 16, 2013 12:46 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
To address the original question: it does appear that once you have turned a menu separator invisible, you cannot make it visible again. That seems like a bug to me. I haven't checked Feedback yet.

Tested under Windows 7, RB 2012r1.1

Dave's test indicates that it works on Mac.


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Thu May 16, 2013 7:17 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
timhare wrote:
To address the original question: it does appear that once you have turned a menu separator invisible, you cannot make it visible again. That seems like a bug to me. I haven't checked Feedback yet....

Dave's test indicates that it works on Mac.


Tim,

Yes, the fact that the program works on a Mac IS good news.

I think that you, Dave, kermit, and others have gone way beyond the call of duty in your attempts to make sense out of this one.

There are a number of things I could (and should) be doing now. One is to re-read chapter 5 in the Tutorial plus all the notes posted in this thread.

Then what I might try as a possible solution would be to delete MenuBar1 entirely, add a new MenuBar, and hope that RB has forgotten about the previous one.

Another possible solution (but it may not be possible) would be to remove the separators and see if I can at least work things out so that the two-item File menu shows up just once and the larger-item File menu consistently after that, even if it is missing the separators.

If I get something working, I'll post a note here, even if my "solution" is not cosmetically pleasing. If worse went to worst, I could replace the MenuBar with, say, something like a bunch of PushButtons.

Thanks to everyone for your kindness shown in the time you spent on this (supposedly) "simple" question....

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: A Simple Menu Question (I think)
PostPosted: Sat May 18, 2013 4:53 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
Well, I made some compromises (no menu items for separators, EditCopy, EditPaste, EditSelectAll....), but I think my menu now does most of what I want it to do (unless it still has a bug that I haven't found and fixed). I learned a lot from the posts people made (and will continue to study those posts along with Real Software's comments on menus), but I don't think I'll pursue the topic further on the Forums for now, since I have made enough progress to get the menu working for my immediate needs.

Thanks to everyone for helping me get there. You've more than deserved a vacation from that topic. As usual, whatever I've learned and put into practice I make available as an (inadequate) "thank you" for your help. You can find the latest version of my CodeHelper program here:

http://traver.org/ch/ch115.rbp

The previous version (primarily because of menu problems) did not allow you to do the complete list of options I intended people to have: open, print, and save (extracted or edited) source code, XML files, and the results of analysis (plus use copy, paste, select all, etc., even if they don't appear on the present menu).

By the way, the latest version is not guaranteed to be without any bugs, but if one should show up, I should -- from what I know now -- be able to fix it ("famous last words"?).

Barry Traver


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group