home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / YellowBox / Kits / MiscTableScroll-138.1 / Palettes / MiscTableScroll / Framework / MiscRadioTracker.M < prev    next >
Encoding:
Text File  |  1998-03-31  |  3.4 KB  |  90 lines

  1. //=============================================================================
  2. //
  3. //    Copyright (C) 1995-1997 by Paul S. McCarthy and Eric Sunshine.
  4. //        Written by Paul S. McCarthy and Eric Sunshine.
  5. //                All Rights Reserved.
  6. //
  7. //    This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the authors
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "License.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //    
  14. //=============================================================================
  15. //-----------------------------------------------------------------------------
  16. // MiscRadioTracker.M
  17. //
  18. //    Radio-mode selection tracking.
  19. //
  20. //    NOTE *1*
  21. //        We emulate Matrix behavior here.  In radio mode if the mouse 
  22. //        goes up and the shift-key is held down then the cell is 
  23. //        deselected.  Since keyboard events are treated like mouse 
  24. //        events we do the same for keyUp events -- however since we 
  25. //        don't actually receive keyUp events, we also perform special 
  26. //        checking for the shift-key modifier in -mouseDown: when the 
  27. //        event is a keyboard event.  
  28. //
  29. //-----------------------------------------------------------------------------
  30. //-----------------------------------------------------------------------------
  31. // $Id: MiscRadioTracker.M,v 1.5 96/12/30 09:13:09 sunshine Exp $
  32. // $Log:    MiscRadioTracker.M,v $
  33. //  Revision 1.5  96/12/30  09:13:09  sunshine
  34. //  v107.1: All access to the selection now goes through MiscTableBorder.
  35. //  
  36. //  Revision 1.4  96/12/30  03:12:01  sunshine
  37. //  v104.1: Selected-slot was removed from SparseSet and promoted to
  38. //  TableBorder.
  39. //  
  40. //  Revision 1.3  96/05/07  02:12:34  sunshine
  41. //  For OpenStep conformance, keyboard events are now treated the same as
  42. //  mouse events (i.e. one must use the same modifiers with keyboard events
  43. //  as one does with mouse events rather than the behavior being different
  44. //  for keyboard events).  Ditched -keyDown:atPos: method.
  45. //-----------------------------------------------------------------------------
  46. #import "MiscRadioTracker.h"
  47. #import "MiscSparseSet.h"
  48. #import "MiscTableBorder.h"
  49.  
  50.  
  51. @implementation MiscRadioTracker
  52.  
  53. //-----------------------------------------------------------------------------
  54. // mouseDown:atPos:
  55. //-----------------------------------------------------------------------------
  56. - (void) mouseDown:(NSEvent*) event atPos:(MiscCoord_V)pos
  57.     {
  58.     if ([event type] == NSKeyDown &&                // NOTE *1*
  59.         ([event modifierFlags] & NSShiftKeyMask) != 0 &&
  60.         border->hasSelection() && pos == border->selectedSlot())
  61.     border->selectNone();
  62.     else
  63.     border->selectOne( pos );
  64.     }
  65.  
  66.  
  67. //-----------------------------------------------------------------------------
  68. // mouseDragged:atPos:
  69. //-----------------------------------------------------------------------------
  70. - (void) mouseDragged:(NSEvent*) event atPos:(MiscCoord_V)pos
  71.     {
  72.     if (border->goodPos(pos))
  73.     border->selectOne( pos );
  74.     else
  75.     border->selectNone();
  76.     }
  77.  
  78.  
  79. //-----------------------------------------------------------------------------
  80. // mouseUp:atPos:
  81. //-----------------------------------------------------------------------------
  82. - (void) mouseUp:(NSEvent*) event atPos:(MiscCoord_V)pos
  83.     {
  84.     if (([event modifierFlags] & NSShiftKeyMask) != 0 &&    // NOTE *1*
  85.     border->goodPos(pos) && border->isSelected(pos))
  86.     border->selectNone();
  87.     }
  88.  
  89. @end
  90.