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

Username:   Password: 
 RegisterRegister   
 Button help!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nathan4102




PostPosted: Mon Mar 18, 2013 6:39 pm   Post subject: Button help!

What is it you are trying to achieve?

A Clickable button.


What is the problem you are having?

When I make a button using the View.Set Parameter "offscreenonly", my buttons aren't clickable.


Describe what you have tried to solve this problem

I have tried calling View.Set again after I do my animations before I print my button, but this doesn't make it clickable. I'm not really sure what else to do since I'm still pretty novice with Turing.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

This is the code for my program. The button in question is found on line 70 of 75. My code is probably messy and has some imperfections, I'll clean it up later, you don't have to do that. Smile

Turing:


import GUI

var imageX : int := -700
var imageY : int := 400
var counter : int := 1
var Background1 : int := Pic.FileNew ("Background1.jpg")
var TitleImage : int := Pic.FileNew ("TitleImage.bmp")
var NameImage : int := Pic.FileNew ("NameImage.bmp")
var half, done : boolean := false

procedure NextSlide
end NextSlide

procedure MoveTitleIn (image, waitTime, halfX : int)
    if counter = 0 then
        half := true
        delay (waitTime)
    elsif imageX < halfX then
        counter := counter + 1
    else
        counter := counter - 1
    end if
    imageX := imageX + counter
    cls
    Pic.Draw (Background1, 0, 0, picCopy)
    Pic.Draw (image, imageX, imageY, picMerge)
    View.Update
end MoveTitleIn

procedure MoveTitleOut (image : int)
    if imageX < 1265 then
        counter := counter + 1
    else
        done := true
    end if
    imageX := imageX + counter
    cls
    Pic.Draw (Background1, 0, 0, picCopy)
    Pic.Draw (image, imageX, imageY, picMerge)
    View.Update
end MoveTitleOut

procedure ImageInAndOut (image, waitTime, halfX : int)
    loop
        if half = false then
            MoveTitleIn (image, waitTime, halfX)
        else
            MoveTitleOut (image)
        end if

        if done = true then
            exit
        end if
        delay (4)
    end loop
    imageX := -900
    counter := 1
    half := false
    done := false
end ImageInAndOut

View.Set ("Graphics:1265;915, offscreenonly")

Pic.Draw (Background1, 0, 0, picCopy)
Pic.Draw (TitleImage, imageX, imageY, picMerge)

ImageInAndOut (TitleImage, 2500, -225)
ImageInAndOut (NameImage, 2500, -320)

var button : int := GUI.CreateButton (1150, 865, 0, "Next Slide", NextSlide)
View.Update

loop
    exit when GUI.ProcessEvent
end loop



Please specify what version of Turing you are using
Turing 4.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon Mar 18, 2013 6:53 pm   Post subject: RE:Button help!

It looks to me like your button works just fine. It just doesn't do anything. It calls NextSlide. What does NextSlide do?
Nathan4102




PostPosted: Mon Mar 18, 2013 7:11 pm   Post subject: Re: Button help!

I havn't coded that bit yet. For me, the button doesn't work though. When I click it, nothing happens, and when I stop, it spawns a new window and highlights a delay in function ProcessEvent, which I guess means its still looking for the button press. If I don't do offscreenonly for View.Set though, it works fine, although the animations flicker really badly. Any ideas? Confused
Insectoid




PostPosted: Mon Mar 18, 2013 7:20 pm   Post subject: RE:Button help!

The button does work. Nothing happens because the button doesn't do anything yet. Why not try outputting some text inside NextSlide?
Nathan4102




PostPosted: Tue Mar 19, 2013 12:44 pm   Post subject: RE:Button help!

Whoops, my bad. Thanks!
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  [ 5 Posts ]
Jump to:   


Style:  
Search: