Beginner Questions
#1
Big Grin 
Hello,

So I've just started looking at yab and what it can and can't do, and I've run across a couple of questions (so far).

1. With a TEXTCONTROL, how can I tell if the ENTER key has been pressed?
2. I can create RADIOBUTTONS and SET them, but how do I tell which one the user has set?

Thanks for any help!
Reply
#2
#!yab

doc Place a description of your
doc program here.
doc
doc Author, date, license

// set DEBUG = 1 to print out all messages on the console
DEBUG = 1

OpenWindow()

// Main Message Loop
dim msg$(1)
while(not leavingLoop)
nCommands = token(message$, msg$(), "|")

for everyCommand = 1 to nCommands
if(DEBUG and msg$(everyCommand)<>"") print msg$(everyCommand)

switch(msg$(everyCommand))
case "_QuitRequested"
case "MainWindow:_QuitRequested"
leavingLoop = true
break
default

end switch
if (left$(msg$(everyCommand),5)="Test:" )DRAW FLUSH "printtext"Big GrinRAW TEXT 20,20, "Enter pressed and the text was changed on textcontrol", "printtext"
if (left$(msg$(everyCommand),5)="Radio" )DRAW FLUSH "printtext"Big GrinRAW TEXT 20,20, msg$(everyCommand)+" button was changed.", "printtext"


next everyCommand

wend

CloseWindow()

end


// Setup the main window here
sub OpenWindow()
window open 100,100 to 600,500, "MainWindow", "Main Window"
Textcontrol 20,20 to 100,50, "Test","Test","","MainWindow"
radiobutton 20,80, "Radio1", "Classic", true, "MainWindow"
radiobutton 20,100, "Radio2", "Jazz", false, "MainWindow"
radiobutton 20,120, "Radio3", "Pop", false, "MainWindow"
view 10,150 to 490,180,"printtext","MainWindow"


return
end sub

// Close down the main window
sub CloseWindow()
window close "MainWindow"
return
end sub
Reply
#3
Thanks! I'll have a poke at this and figure out how to work it in.
Reply
#4
Thanks to your info, I now have a mostly functional 30-something year old game running in it's own GUI.

[Image: dod3.png]

It still needs a bit of polishing yet (like, getting the close window button to work).

One thing I would like to do, but haven't quite figure out yet, is how to get the TEXTEDIT area to scroll to the bottom when text is added.
Reply
#5
this part handles the close window button:
Code:
while(not leavingLoop)
for everyCommand = 1 to nCommands
if(DEBUG and msg$(everyCommand)<>"") print msg$(everyCommand)

switch(msg$(everyCommand))
case "_QuitRequested"
case "MainWindow:_QuitRequested"
leavingLoop = true
break
default

end switch
wend

CloseWindow()     // Directs to a clean-up and end program subroutine.

end

I'm tot sure what you want the text to do.
Reply
#6
What I wanted was for the text in the left text area to scroll down when text was added to it. I figured out a way of doing it, but it didn't look right. So, for the time being it just clears the screen before it fills up.

What I'm wondering now is if there's a way to increase the font size and have the views scale up to keep the same amount of columns.
Reply
#7
textedit set Option$ = "fixed" value$ = str$(point) sets the font to system fixed font of point size (number from 7 and up

textedit set "fixed" ,"20"

Sets the font to the system fixed font at 20 points.
Reply
#8
That'll be handy to know. Now I gotta figure out how to scale everything when there's a larger font size.
Reply
#9
This may come in handy:

Code:
sub ptext(lne,position,text$, view$)

local charheight, charwidth
charheight = draw get "Max-Text-Height", view$
charheight=charheight
charwidth = DRAW GET "Text-Width", "█", view$
if charwidth=0 then
charwidth = DRAW GET "Text-Width", "-", view$
endif

draw text (position*charwidth),((lne)*charheight), text$, view$


end sub

I use this to ptint text on a view, it gives me good control over text placement. One needs to use a fixed face font to make it work well.
Reply
#10
Cool. I'll give it a look and see what I can do with it.

I finished the original Dungeon of Danger done in Yab. I don't know what to do with it now, but it's done. Now I feel I can go back to work on a sequel (of sorts). Although, if I can work in the font sizing I'll go back to it.

I can't find Atari 8-bit or Commodore 64 fonts in HaikuDepot. I was thinking of changing fonts and color schemes depending on what "computer" one wanted to play it on.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)
Free Web Hosting