[Insight-users] Another FltkImageViewer Keyboard Qustion

Feng Ma mafeng@hotmail.com
Tue, 28 Jan 2003 13:04:55 -0500


Hi,

  I have another quesiton about FltkImageViewer keyboard. I have trouble 
with KEYUP event. In SliceView.h, we don't really use the KEYUP event. I 
tried to modify the viewer to allow faster scrolling while pressing the ">" 
or "<" key. That is, when ">" or "<" is pressed for sometime, the image will 
scroll every 3 or 5 slices, rather than 1 slice. When the key is released, 
the moving pace will restore to 1.

  So I need to capture the KEYUP event. What I found was: whenever there is 
an update() called, the KEYUP event is issued. So, I kept receiving KEYUP 
event. That is not what I want.

  The code segment I changed in SliceView.h is:

  In SliceView::handle() method:

  Add two variables:
  int fastMove = 0; //flag if moving faster than 1
  const int fastMoveVal = 3; //pace of fast moving

  ....

      case FL_KEYUP:
        fprintf(stderr, "***KEY UP***\n");
        fastMove = 0;
        return 0;

        break;

    case FL_KEYBOARD:
    case FL_SHORTCUT:
      key = Fl::event_text()[0];
      switch(key)

      ....
        case '>':
        case '.':
            fprintf(stderr, "fastMove = %d\n", fastMove);
            if( fastMove < fastMoveVal){
                fastMove ++;

      if((int)cWinCenter[cWinOrder[2]]+1>(int)cDimSize[cWinOrder[2]]-1)
                    return 1;
                sliceNum(cWinCenter[cWinOrder[2]]+1);
            }
            else{
                
if((int)cWinCenter[cWinOrder[2]]+fastMoveVal>(int)cDimSize[cWinOrder[2]]-1)
                    return 1;
                sliceNum(cWinCenter[cWinOrder[2]]+fastMoveVal);
            }

          this->update();
          return 1;
          break;

  Thanks.

-Feng


_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail