Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 GUI.CreateMenu .. Help with disappearing issue plz!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
midnite13




PostPosted: Thu Apr 27, 2006 6:37 pm   Post subject: GUI.CreateMenu .. Help with disappearing issue plz!

Hello all,

In order to make my summative evaluation look more elegant, my partner and I have decided to delve into the turing GUI library for ideas. We stumbed upon a function called GUI.CreateMenu, and decided it would suffice. Playing around with it, we coded it so that when the user selected an option, it would display '*option name* selected' (like the help example). However, we encountered this problem...

The menu bar would disappears if the option name is longer than a character! Have you guys experienced this problem before, and if so, did you find a way around it?

Thanks

p.s. if need be, i'll paste the code
Sponsor
Sponsor
Sponsor
sponsor
midnite13




PostPosted: Thu Apr 27, 2006 6:41 pm   Post subject: Solution Found

Sorry if this is considered double posting...

I have found a crude solution to my problem.
It involves including GUI.ShowMenuBar and a bried delay inside the loop containing
'exit when Gui.ProcessEvent'

However, further solutions are appreciated.

p.s. I just read over my previous message and found a lot of grammatical mistakes, sry S=
jamonathin




PostPosted: Thu Apr 27, 2006 7:03 pm   Post subject: (No subject)

Firstly, since you are using GUI.CreateMenu - or mainly any gui for that matter, ditch the delay, and ONLY create it once. My guess is your program won't be complicated enough where you would need to reset the value of it.

Now to answer your question; Nope. I have never run into that problem you speak of. I went and took a look at Turing's Example and added more than 1 character to the option, and it still works.

Here's what you should look for then since your code isn't present. Check for any of these:

cls
View.Update (you shouldn't be using this with GUI anyways - no real need)
locate
Draw.Anything
Font.Draw

And pretty much anything thing else that your put on your screen. If you put up your code I'm shure your question will be solved much faster Wink .
midnite13




PostPosted: Thu Apr 27, 2006 7:59 pm   Post subject: (No subject)

[quote="jamonathin"] Now to answer your question; Nope. I have never run into that problem you speak of. I went and took a look at Turing's Example and added more than 1 character to the option, and it still works.
[quote]
Hello jamonathin, thanks for replying!

Sorry if I wasn't clear before, here is an example of a code where the problem occurs. This arises if you try to modify the code slightly:

code:

import GUI in "%oot/lib/GUI"

% This portion is straight from the help file.
View.Set ("graphics:250;150,nobuttonbar")
var first, second : int                    % The menus.
var item : array 1 .. 12 of int         % The menu items.
var name : array 1 .. 12 of string (20) :=
    init ("Quit", "---", "A dfdsf", "B", "---", "C", "D",
    "Disable B Menu Item", "Enable B Menu Item", "---",
    "Disable First Menu", "Enable First Menu")

procedure MenuSelected
    for i : 1 .. 12
          if item (i) = GUI.GetEventWidgetID then
            locate (maxrow, 1)
            put name (i) + " selected               " ..
        end if
    end for
end MenuSelected

%Create the menus
 first := GUI.CreateMenu ("First")
 item (1) := GUI.CreateMenuItem (name (1), GUI.Quit)
 for cnt : 2 .. 7
         item (cnt) := GUI.CreateMenuItem (name (cnt),
         MenuSelected)
end for

second := GUI.CreateMenu ("Second")
for cnt : 8 .. 12
        item (cnt) := GUI.CreateMenuItem (name (cnt),
        MenuSelected)
end for

loop
    exit when GUI.ProcessEvent
end loop

I altered the code so that the second menu items display the *option name* + selected. The first menu works perfect, but if you click on any item in the second menu, you'll see what I'm talking about.
However, I replaced
code:

loop
    exit when GUI.ProcessEvent
end loop

With this...
code:

loop
    GUI.ShowMenuBar
    delay (150)           %The delay is only to stop it from flickering
    exit when GUI.ProcessEvent
end loop

and it works Razz
do_pete




PostPosted: Thu Apr 27, 2006 9:18 pm   Post subject: (No subject)

GUI.Refresh will sove your problem.
midnite13




PostPosted: Thu Apr 27, 2006 10:17 pm   Post subject: (No subject)

do_pete wrote:
GUI.Refresh will solve your problem.


It shows up as a variable when I type this in...
Does it work for Turing 4.0.4?
do_pete




PostPosted: Fri Apr 28, 2006 11:30 am   Post subject: (No subject)

It should work. How are you using it in your code?
midnite13




PostPosted: Sun Apr 30, 2006 3:48 pm   Post subject: (No subject)

do_pete wrote:
It should work. How are you using it in your code?


Again, thanks for all your help.
I inserted GUI.Refresh into my code here:

code:

loop
    GUI.Refresh
    exit when GUI.ProcessEvent
end loop

Is this correct?
Sponsor
Sponsor
Sponsor
sponsor
BenLi




PostPosted: Mon May 01, 2006 4:05 pm   Post subject: (No subject)

Well if you're trying to spruce up your FP, maybe you should create your own GUI. I think we all agree Turing's looks like crap
HellblazerX




PostPosted: Mon May 01, 2006 5:28 pm   Post subject: (No subject)

The problem here has nothing to do with refreshing the GUI or whatnot. This is your problem:

code:
put name (i) + " selected               " ..


Why do you have all that extra spaces? Because when you output those names, your adding all those spaces in as well. What is happening is because your output is at the bottom, it will run out of space, and because the size of your window, it will "shift" the screen down in the attempt to put those spaces in, and what happens is your menu bar gets erased out. Remove those spaces, and enlarge your window, and you'll be fine.

And if you're thinking of making your own GUI, then you might as well make it your FP, because there's a lot that goes into a making your own GUI module. There's a reason why it's already been made.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: