Beginner Questions - Printable Version +- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum) +-- Forum: Programming in yab (https://yab.orgfree.com/forum/forumdisplay.php?fid=1) +--- Forum: Help with programs (https://yab.orgfree.com/forum/forumdisplay.php?fid=4) +--- Thread: Beginner Questions (/showthread.php?tid=123) |
Beginner Questions - MrEntropy - 04-07-2020 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! RE: Beginner Questions - bbjimmy - 04-08-2020 #!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"RAW TEXT 20,20, "Enter pressed and the text was changed on textcontrol", "printtext" if (left$(msg$(everyCommand),5)="Radio" )DRAW FLUSH "printtext"RAW 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 RE: Beginner Questions - MrEntropy - 04-09-2020 Thanks! I'll have a poke at this and figure out how to work it in. RE: Beginner Questions - MrEntropy - 04-11-2020 Thanks to your info, I now have a mostly functional 30-something year old game running in it's own GUI. 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. RE: Beginner Questions - bbjimmy - 04-12-2020 this part handles the close window button: Code: while(not leavingLoop) I'm tot sure what you want the text to do. RE: Beginner Questions - MrEntropy - 04-13-2020 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. RE: Beginner Questions - bbjimmy - 04-14-2020 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. RE: Beginner Questions - MrEntropy - 04-19-2020 That'll be handy to know. Now I gotta figure out how to scale everything when there's a larger font size. RE: Beginner Questions - bbjimmy - 04-21-2020 This may come in handy: Code: sub ptext(lne,position,text$, view$) 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. RE: Beginner Questions - MrEntropy - 04-22-2020 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. |