Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9211705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:21:27+00:00 2026-06-18T01:21:27+00:00

What I want is to be able to change the value of a variable

  • 0

What I want is to be able to change the value of a variable through the window with the graphics, not from the code. It’s ok if there are several fixed values and there is a choice only between them. Can you please give me some ideas?

I was thinking of something like this:
|–|–|–|–|–|, where each vertical line repesents a value and when you click the line, the value is changed, but it’s a bit difficult for me to implement this. Any simpler ideas

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:21:29+00:00Added an answer on June 18, 2026 at 1:21 am

    Here’s a quick keyboard-based solution (I’m assuming C++):

    Let’s assume your values are all in an array called values:

    const int NUM_VALUES = 5;
    int values[NUM_VALUES];
    

    Keep track of the selected value:

    int selectionIndex = 0;
    

    Make a function to handle key presses:

    void keyPressed (unsigned char key, int x, int y) { 
        if (key == GLUT_KEY_LEFT) {
            if(--selectionIndex < 0)
                selectionIndex = NUM_VALUES - 1;
        } 
        else if (key == GLUT_KEY_RIGHT) {
            if(++selectionIndex >= NUM_VALUES)
                selectionIndex = 0;
        }  
        else if (key == GLUT_KEY_UP) {
            values[selectionIndex]++;
        }  
        else if (key == GLUT_KEY_DOWN) {
            values[selectionIndex]--;
        }   
    }
    

    Finally, in your initialization, link keyPressed to glutKeyboardFunc:

    glutKeyboardFunc(keyPressed); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run pdb, step through the code, and at some point change
When we want to change the value of an ordinary variable by in a
I want to be able to change the appearance of the mouse cursor as
I want to be able to do this: the TextView to change its size
I want a form where user can change password. I am able to encrypt
I want the user to be able to select an option, which would change
I want to be able to replicate only the folder structure (not the contents)
Im fairly new to coding... i want to be able to change a PHP
Is there some window variable in javascript that I can use or a way
I am trying to be able to change the value of a hidden field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.