[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keyboard events




By the way, are people aware that you can trap control keys with the hack
(either version).  At least for me, Control+a-z map to keys 1B-26B.  C-p for
print anyone?  Haven't tried this one on anything but Unix.  Just in case people
couldn't find the post I've reattached the latest hack with this modification. 
Just run tt and try various keys, including control+letter and arrows.  If
people want to experiment along these lines on other platforms/os's, I'd be
willing to collect the results and bundle the routine into something generically
useable and distributeable.  Maybe then RSI would take notice and work to
include a less hackish alternative.

JD

-- 
 J.D. Smith                             /*\    WORK: (607) 255-6263
 Cornell University Dept. of Astronomy  \*/	     (607) 255-5842
 304 Space Sciences Bldg.               /*\     FAX: (607) 255-5875  
 Ithaca, NY 14853                       \*/
pro catch_text,ev
   type=tag_names(ev,/STRUCTURE_NAME)
   erase
   case type of
      'WIDGET_TEXT_SEL': begin
         widget_control, ev.id, get_uvalue=ulrdo
         widget_control, ev.id,SET_TEXT_SELECT=ulrdo[4],SENSITIVE=0
         case ev.offset of
            ulrdo[0]: xyouts,.5,.5,/NORMAL,'Up',   CHARSIZE=2.,ALIGNMENT=.5
            ulrdo[1]: xyouts,.5,.5,/NORMAL,'Left', CHARSIZE=2.,ALIGNMENT=.5
            ulrdo[2]: xyouts,.5,.5,/NORMAL,'Right',CHARSIZE=2.,ALIGNMENT=.5
            ulrdo[3]: xyouts,.5,.5,/NORMAL,'Down', CHARSIZE=2.,ALIGNMENT=.5
            else:
         endcase
         widget_control, ev.id,/SENSITIVE,/INPUT_FOCUS

      end
      'WIDGET_TEXT_CH': begin 
         if ev.ch le 26 then $
          xyouts,.5,.5,/NORMAL,'C-'+strtrim(ev.ch+96b,2),CHARSIZE=2., $
          ALIGNMENT=.5 $
         else $
          xyouts,.5,.5,/NORMAL,string(ev.ch),CHARSIZE=2.,ALIGNMENT=.5

      end 
   endcase

end

pro tt_event,ev
   type=tag_names(ev,/STRUCTURE_NAME)
   widget_control, ev.top,GET_UVALUE=info
   if type eq 'WIDGET_TRACKING' then begin
      widget_control, info.key,/INPUT_FOCUS
      return
   endif

   if ev.type le 1 then widget_control, info.key,/INPUT_FOCUS
   str=string(format='(2(I2.2,:,":"))',ev.X,ev.Y)
   case ev.type of
      0:str='P'+str
      1:str='R'+str
      2:str='M'+str
      else:str='*'
   endcase
   erase
   xyouts,.5,.5,/NORMAL,str, CHARSIZE=1.,ALIGNMENT=.5
end

pro tt
   base=widget_base()
   draw=widget_draw(base,XSIZE=60,YSIZE=60,/TRACKING_EVENTS,/MOTION_EVENTS, $
                    /BUTTON_EVENTS)
   case !VERSION.OS_FAMILY of
      'unix': ulrdo=[1,3,5,7,4]
      'Windows': ulrdo=[1,4,6,9,5]
      else: message,'Not supported.'
   endcase
   key=widget_text(base,/ALL_EVENTS,FRAME=0,XSIZE=2,YSIZE=3, $
                   VALUE=['**','**','**'], EVENT_PRO='catch_text',UVALUE=ulrdo)
   widget_control, base,SET_UVALUE={draw:draw,key:key},/REALIZE
   widget_control, key,SET_TEXT_SELECT=ulrdo[4],/INPUT_FOCUS
   XManager,'tt',base,/NO_BLOCK
end