Thread: Menu system (Using the arrow keys)

  1. #1
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    Menu system (Using the arrow keys)

    How do you make a menu system for a console application. Not just a display, and you enter a number, but where you can use the arrow keys and each selection is highlighted or something. How do I do that?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    text color and background color in the console have been talked about a lot. search for those threads and take it one step at a time.
    first print a menu.
    use methods from above search to highlight an item.
    use getch() check for valid keypresses then if needs be move the highlighting by reprinting the menu over itself but with the colours changed as you need.

    simple enough with a little thought.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Ok, make you a file in Paint or whatever you use that has the same deminsions in PIXELS. For example, if you use mode 13h you would make it 320 pixels by 200 pixels. Now this is the background or backdrop. Now useing the text tool write all your options on there, once you get the background ready. Now make you a file of an arrow, or box or whatever, that will show which option is selected. Make the program draw the backdrop. Then the arrow pic you drew left of the first option. Then use getch(); and then a switch that checks if the user pressed up or down. If up, then draw the backdrop, and draw the arrow left of the option above the option you were on. If you are at the top, make it draw the arrow at the option at the far bottom. You should have a variable that holds what option you have selected. If the user presses space bar, it reads what the option variable says, then it draws the backdrop to the next set of options. And the whole proccess starts all over again. I made an attractive menu in about 15 mins. And it took me about 2 mins to draw all the backdrops and arrow.

  4. #4
    Also, if you dont want to use graphics, just print all options, then substitute the arrow pic with > or something.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arrow keys as keyboard Input
    By bradleym83 in forum C++ Programming
    Replies: 3
    Last Post: 12-01-2005, 09:39 PM
  2. Movement with arrow keys
    By louis_mine in forum C Programming
    Replies: 3
    Last Post: 02-06-2005, 04:35 PM
  3. Interfacing with arrow keys...
    By adityakarnad in forum Game Programming
    Replies: 1
    Last Post: 08-30-2003, 10:25 PM
  4. Arrow keys!
    By Paninaro in forum C Programming
    Replies: 8
    Last Post: 06-26-2002, 07:39 PM
  5. arrow keys, ctrl and alt keys
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-25-2002, 03:53 PM