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

Username:   Password: 
 RegisterRegister   
 Using mousewhere while using GUI
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jai_eun




PostPosted: Thu Jan 01, 2009 3:12 pm   Post subject: Using mousewhere while using GUI

I am having some trouble and hope u can help me
The problem is i can not use ranges and mousewhere to act as a button for me it executes properly but when i click within that range nothing happens
I think this is because my program is also using GUI to create other buttons within the program but im am still not sure.

Here is my source code, it is not finished but what i need help on is there.
Just click on the lesson portion of main menu and click next within the lesson procedure



Turing:

%Dec/22/08
%This program will teach you about geometric shapes and test your knowledge with a quiz.

%Set screen up
import GUI
setscreen ("offscreensonly")
View.Set ("graphics")


%Declaration Section
var mainWin := Window.Open ("position:100;100,graphics:650;400")
var rangeX, rangeY, button : int



%Program Title
procedure title
    locate (1, 32)
    colour (15)
    put "Geometric Shapes"
end title


%Program goodBye
procedure goodBye
    cls
    title
    %Animated Circle
    for x : 60 .. 315
        drawfilloval (x - 1, 220, 50, 50, 0)
        drawfilloval (x, 220, 50, 50, 70)
        delay (10)
    end for



    colour (83)
    locate (22, 28)
    put "This program was written by:"
    locate (23, 33)
    put "???????"
    loop
        exit when hasch
    end loop
    Window.Close (mainWin)

end goodBye





%Program Quiz
procedure userInput
    cls
    title
    put "Quiz time"
end userInput




%Program Lesson
procedure display
    cls
    title
    colour (86)
    locate (4, 30)
    put "Lesson 1: Circles"
    colour (103)
    locate (7, 10)
    put "1)The perimeter of a circle is known as it's circumference"
    locate (9, 10)
    put "2)The measure which runs along the centre of a circle is the diameter"
    locate (11, 10)
    put "3)Circles were used as the basis for creating wheels"
    locate (19, 40)
    put "Next"
    colour (86)
    locate (13, 10)
    put " Associated word: Circumference"
    drawbox (300, 82, 360, 114, 86)
    mousewhere (rangeX, rangeY, button)
    if button = 1 then
        if (rangeX >= 300 and rangeX <= 360) and (rangeY >= 82 and rangeY < 114) then
            cls
            colour (86)
            locate (4, 30)
            put "Lesson 2: Squares"
        end if
    end if

end display



%Program mainMenu
procedure mainMenu

    cls
    title
    %Main menu background
    drawfilloval (20, 300, 10, 10, 86)
    drawfilloval (200, 230, 10, 10, 92)
    drawfilloval (50, 200, 10, 10, 70)
    drawfilloval (200, 380, 10, 10, 70)
    drawfilloval (500, 200, 10, 10, 86)
    drawfilloval (520, 360, 10, 10, 92)
    drawfilloval (440, 110, 10, 10, 70)
    drawfilloval (580, 140, 10, 10, 92)
    drawfilloval (300, 40, 10, 10, 92)
    drawfilloval (150, 120, 10, 10, 86)
    drawfilloval (400, 360, 10, 10, 86)
    drawfilloval (405, 250, 10, 10, 92)


    %Circles & Faces
    drawfilloval (30, 30, 23, 23, 86)
    drawfilloval (20, 30, 3, 6, 22)
    drawfilloval (40, 30, 3, 6, 22)
    drawfilloval (30, 20, 3, 3, 62)
    drawfillbox (27, 22, 33, 25, 62)
    drawfilloval (93, 363, 23, 23, 86)
    drawarc (83, 363, 4, 3, 0, 180, 22)
    drawfilloval (105, 363, 3, 6, 22)
    drawfilloval (94, 355, 3, 4, 62)
    drawfillbox (90, 355, 97, 360, 62)
    %Squares & Faces
    drawfillbox (10, 60, 50, 100, 70)
    drawline (15, 90, 24, 85, 22)
    drawline (24, 85, 15, 80, 22)
    drawline (45, 90, 36, 85, 22)
    drawline (36, 85, 45, 80, 22)
    drawfilloval (30, 75, 4, 4, 86)
    %Ovals & Face
    drawfilloval (610, 370, 28, 23, 86)
    drawarc (620, 370, 4, 3, 0, 180, 22)
    drawarc (600, 370, 4, 3, 0, 180, 22)
    drawfilloval (610, 360, 3, 3, 62)
    drawfillbox (607, 360, 613, 363, 62)
    drawfilloval (545, 30, 28, 23, 70)
    drawfilloval (535, 30, 3, 6, 22)
    drawfilloval (555, 30, 3, 6, 22)
    drawfilloval (545, 20, 3, 3, 86)
    %Rectangle & Face
    drawfillbox (580, 10, 640, 50, 68)
    drawline (590, 40, 599, 35, 22)
    drawline (599, 35, 590, 30, 22)
    drawfilloval (620, 35, 3, 6, 22)
    drawfilloval (610, 20, 5, 3, 86)
    drawfillbox (590, 340, 635, 270, 70)
    drawfilloval (603, 320, 3, 6, 22)
    drawfilloval (622, 320, 3, 6, 22)
    drawfilloval (612, 300, 4, 4, 86)
    drawfillbox (608, 300, 616, 305, 86)
    %Triangle & Face
    var x : array 1 .. 3 of int := init (10, 40, 70)
    var y : array 1 .. 3 of int := init (340, 390, 340)
    Draw.FillPolygon (x, y, 3, 92)
    drawline (32, 365, 37, 360, 22)
    drawline (37, 360, 32, 355, 22)
    drawline (45, 360, 50, 365, 22)
    drawline (45, 360, 50, 355, 22)
    drawfilloval (41, 350, 3, 3, 86)
    drawfillbox (38, 350, 44, 355, 86)
    %Main menu buttons

    var lessonButton : int := GUI.CreateButtonFull (285, 250, 0, "Lesson", display, 0, '^L', false)
    var quizButton : int := GUI.CreateButtonFull (287, 200, 0, "Quiz!", userInput, 0, '^Q', false)
    var quitButton : int := GUI.CreateButton (292, 150, 0, "Exit", goodBye)


    loop
        exit when GUI.ProcessEvent
    end loop

end mainMenu




%Program Introduction
procedure introduction
    title
    colour (103)
    locate (3, 22)
    put "Learn about various geometric shapes"
    locate (4, 28)
    put "and test your knowledge"
    locate (5, 35)
    put "with a quiz"

    var menuButton : int := GUI.CreateButton (280, 50, 0, "Go to Menu", mainMenu)

    loop
        exit when GUI.ProcessEvent
    end loop
end introduction


%Main Program
introduction
mainMenu
display
userInput


Mod Edit: Syntax tags are better then quote tags to post code
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Jan 01, 2009 3:17 pm   Post subject: RE:Using mousewhere while using GUI

Don't use the built in GUI. Make your own buttons. They look nicer and work more often than the GUI.
Tony




PostPosted: Thu Jan 01, 2009 7:32 pm   Post subject: RE:Using mousewhere while using GUI

you are using mousewhere just once (it's not inside a loop).
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Homer_simpson




PostPosted: Thu Jan 01, 2009 8:20 pm   Post subject: Re: Using mousewhere while using GUI

it's gotto look like this:


Mod Edit: Don't just post the solution. Thanks Smile
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  [ 4 Posts ]
Jump to:   


Style:  
Search: