This question may be somewhat trivial, but I'm stumped none the less.

The goal is to create a 'selection box' on the screen such as for selecting units in an rts game.

I'll just give the pseudo-code, its the idea that's important
main loop is set up as such:

     if(mouse_b &1)
          delay timer
          if(mouse_b &1) //the button is still pressed

//check other inputs
//update game logic
//draw stuff

now, inside the drag_leftclick() function, it has to wait in a while loop until you release the button, record the x,y before and after coordinates and go about business. The problem is this completely freezes the rest of program while it waits for the user to finish selecting.

I've a pretty good grasp on c++ but still learning. I strongly suspect the answer involves multithreading. Does anyone have other suggestions?? And does anyone know a good intro to multithreading, if not for this, for sometime later?

Thanks all

One suggestion would be to just keep the initial click position in a variable at the moment of click, as well as the current held position each frame, draw a rectangle using those points. So instead of doing a while loop, you already know where the initial click was, and your after click continues to update every frame instead of waiting for the mouse to be released.

The way I do my input is by using 3 states: up, clicked/pressed and down. The up state is when the mouse button isn't pressed at all. The clicked state should only be active for a single frame, and that's the first frame of which the mouse button is down. The down state is any subsequent frame after the clicked state in which the mouse button is still down. You can just use a series of if statements in your mouse polling function to determine what effects should take place during states, as well as switching from one state to another.

When you do the input this way, it gives you the ability to handle any mouse click or key press in the same fashion.

Thats a pretty clever idea, I like it. I already had case statements set up based on the handful of 'clickable' things in the world for a single click case. Adaption should be relatively easy from here.

Thanks a ton