Help with Buttons?
Author |
Message |
anniejellah
|
Posted: Sat Jun 08, 2013 10:25 pm Post subject: Help with Buttons? |
|
|
What is it you are trying to achieve?
I'm trying to make a program (that teaches the user simple lessons and a quiz at the end but i haven't gotten to that part yet) that navigates using buttons
What is the problem you are having?
I can't seem to figure out how to get the buttons to work. specifically, my "PREVIOUS" button does not work properly.
Describe what you have tried to solve this problem
I've looked at other button tutorials and posts on this site, and have tried messing around with my code but i can't seem to figure it out ://
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Here is all the code w/ the irrelevant text taken out and replaced w/ "THIS IS _____" to label each procedure
Turing: |
%Set Screen
import GUI
%GLOBAL VARIABLES
%Windows
var win3 : int := Window.Open ("graphics:max,max; nobuttonbar; title:QUIZ WINDOW")
var win2 : int := Window.Open ("graphics:700,500; position:center,center; nobuttonbar; title:LESSON WINDOW")
var mainWin : int := Window.Open ("graphics:600,350; position:center,top; title:MAIN MENU")
%Buttons (PREVIOUS/NEXT LESSON BUTTONS??)
var menuButton, exitButton, prvButton, cntButton, lsn1Button, lsn2Button, lsn3Button, lsn4Button, lsn5Button : int
var lsn6Button, lsn7Button, lsn8Button, lsn9Button, lsn10Button, lsn11Button, lsn12Button : int
%Fonts
var font1 : int := Font.New ("Verdana:12")
%PROCEDURES
%Forward Procedures
forward proc menu
forward proc lsn1
forward proc lsn1pg2
forward proc lsn2
forward proc lsn3
forward proc lsn4
forward proc lsn5
forward proc lsn6
forward proc lsn7
forward proc lsn8
forward proc lsn9
forward proc lsn10
forward proc lsn11
forward proc lsn12
%Title
proc title
cls
var width : int := Font.Width ("Basic Music Theory", Font.New ("Oswald:18:bold"))
Font.Draw ("Basic Music Theory", maxx div 2 - width div 2, maxy - 25, Font.New ("Oswald:18:bold"), black)
end title
%Open Window 2
proc openwin2
GUI.HideWindow (mainWin )
Window.Select (win2 )
Window.Show (win2 )
title
menuButton := GUI.CreateButton (275, 50, 150, "RETURN TO MENU", menu )
end openwin2
%Disabling Buttons
proc disable
GUI.Disable (prvButton )
GUI.Disable (cntButton )
end disable
%LESSONS
%Lesson 1 - THE ALPHABET: Note Names
body proc lsn1
openwin2
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn1pg2, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 1", 1, 300, font1, black)
end lsn1
body proc lsn1pg2
openwin2
GUI.Disable (cntButton )
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn1, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn2, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 1 PAGE 2", 1, 300, font1, black)
end lsn1pg2
%Lesson 2 - NOTE READING AND RHYTHM: Staff, Clefs, and Ledger Lines
body proc lsn2
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn1pg2, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn3, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 2", 1, 300, font1, black)
end lsn2
%Lesson 3 - Note and Rest Values, Dots and Ties
body proc lsn3
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn2, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn4, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 3", 1, 300, font1, black)
end lsn3
%Lesson 4 - Measures and Time Signatures
body proc lsn4
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn3, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn5, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 4", 1, 300, font1, black)
end lsn4
%Lesson 5 - Key Signatures
body proc lsn5
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn4, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn6, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 5", 1, 300, font1, black)
end lsn5
%Lesson 6 - Steps and Accidentals
body proc lsn6
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn5, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn7, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 6", 1, 300, font1, black)
end lsn6
%Lesson 7 - SCALES AND INTERVALS: Major, Minor, Pentatonic
body proc lsn7
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn6, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn8, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 7", 1, 300, font1, black)
end lsn7
%Lesson 8 - Scale Degrees
body proc lsn8
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn7, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn9, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 8", 1, 300, font1, black)
end lsn8
%Lesson 9 - Intervals
body proc lsn9
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn8, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn10, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 9", 1, 300, font1, black)
end lsn9
%Lesson 10 - CHORDS: Basic Chords and the Circle of Fifths
body proc lsn10
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn9, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn11, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 10", 1, 300, font1, black)
end lsn10
%Lesson 11 - Chord Progressions: Arpeggios, Modes, Transposing Chords
body proc lsn11
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn10, 0, KEY_BACKSPACE, false)
cntButton := GUI.CreateButtonFull (500, 50, 150, "CONTINUE", lsn12, 0, KEY_ENTER, false)
Draw.Text ("THIS IS LESSON 11", 1, 300, font1, black)
end lsn11
%Lesson 12 - Key Words and Expression Marks
body proc lsn12
openwin2
disable
prvButton := GUI.CreateButtonFull (50, 50, 150, "PREVIOUS", lsn11, 0, KEY_BACKSPACE, false)
Draw.Text ("THIS IS LESSON 12", 1, 300, font1, black)
end lsn12
%Quiz
proc quiz
GUI.HideWindow (mainWin )
GUI.CloseWindow (win2 )
GUI.ShowWindow (win3 )
Window.Select (win3 )
title
Draw.Text ("THIS IS THE QUIZ", 1, 500, font1, black)
end quiz
%Good Bye
proc goodBye
GUI.CloseWindow (mainWin )
GUI.CloseWindow (win2 )
GUI.CloseWindow (win3 )
end goodBye
%Main Menu
body menu
GUI.Dispose (menuButton )
GUI.HideWindow (win2 )
GUI.HideWindow (win3 )
Window.Select (mainWin )
Window.Show (mainWin )
title
var quizButton : int := GUI.CreateButtonFull (400, 150, 125, "TAKE THE QUIZ!", quiz, 100, KEY_ENTER, true)
exitButton := GUI.CreateButtonFull (400, 75, 125, "EXIT", GUI.Quit, 0, KEY_ESC, false)
lsn1Button := GUI.CreateButton (25, 275, 125, "LESSON ONE", lsn1 )
lsn2Button := GUI.CreateButton (25, 225, 125, "LESSON TWO", lsn2 )
lsn3Button := GUI.CreateButton (25, 175, 125, "LESSON THREE", lsn3 )
lsn4Button := GUI.CreateButton (25, 125, 125, "LESSON FOUR", lsn4 )
lsn5Button := GUI.CreateButton (25, 75, 125, "LESSON FIVE", lsn5 )
lsn6Button := GUI.CreateButton (25, 25, 125, "LESSON SIX", lsn6 )
lsn7Button := GUI.CreateButton (175, 275, 125, "LESSON SEVEN", lsn7 )
lsn8Button := GUI.CreateButton (175, 225, 125, "LESSON EIGHT", lsn8 )
lsn9Button := GUI.CreateButton (175, 175, 125, "LESSON NINE", lsn9 )
lsn10Button := GUI.CreateButton (175, 125, 125, "LESSON TEN", lsn10 )
lsn11Button := GUI.CreateButton (175, 75, 125, "LESSON ELEVEN", lsn11 )
lsn12Button := GUI.CreateButton (175, 25, 125, "LESSON TWELVE", lsn12 )
%Music.PlayFile ("song1.mp3")
end menu
%Introduction
proc intro
GUI.HideWindow (win2 )
GUI.HideWindow (win3 )
var titlepic : int := Pic.FileNew ("Title.bmp")
Pic.DrawSpecial (titlepic, 150, 275, picMerge, picSlideRightToLeftNoBar, 2000)
Draw.Text ("Welcome to TDSB's Basic Music Theory Program! Here you will learn", 1, 250, font1, black)
Draw.Text ("simple music theory in 12 easy lessons!", 1, 225, font1, black)
Draw.Text ("There will even be a quiz at the end to test what you've learned!", 1, 200, font1, black)
Draw.Text ("Oh goody!!", 1, 175, font1, black)
menuButton := GUI.CreateButton (250, 75, 100, "MENU", menu )
end intro
%Main Program
intro
loop
exit when GUI.ProcessEvent
end loop
goodBye
|
Please specify what version of Turing you are using
4.1 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|