mirror of https://github.com/fltk/fltk
Mousewheel fixes.
src/Fl_mac.cxx: - Disable MightyMouse code for the moment - it is crashing on my PowerBook... src/Fl_Scrollbar.cxx: - Fl_Scrollbar::handle() should only return 1 for mousewheel events that it uses. test/sudoku.cxx: - More tweaking. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4654 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
f2019a54cb
commit
ae6ea393c0
|
@ -132,11 +132,13 @@ int Fl_Scrollbar::handle(int event) {
|
|||
if (horizontal()) {
|
||||
if (Fl::e_dx==0) return 0;
|
||||
handle_drag(clamp(value() + linesize_ * Fl::e_dx));
|
||||
return 1;
|
||||
} else {
|
||||
if (Fl::e_dy==0) return 0;
|
||||
handle_drag(clamp(value() + linesize_ * Fl::e_dy));
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
break;
|
||||
case FL_SHORTCUT:
|
||||
case FL_KEYBOARD: {
|
||||
int v = value();
|
||||
|
|
|
@ -799,15 +799,20 @@ static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler,
|
|||
// to me why Apple changed the API on this even though the current API
|
||||
// supports two wheels just fine. Matthias,
|
||||
EventRef event;
|
||||
// fprintf(stderr, "carbonMousewheelHandler: GetEventKind(ev=%p) = %d\n", ev,
|
||||
// GetEventKind(ev));
|
||||
if (GetEventKind(ev)==11) {
|
||||
// if this is a "MightyMouse" event, we need to convert it into a regular
|
||||
// MouseWheel event
|
||||
// fputs("MightyMouse event!\n", stderr);
|
||||
GetEventParameter( ev, kEventParamEventRef, typeEventRef, NULL, sizeof( EventRef ), NULL, &event );
|
||||
} else {
|
||||
// otherwise, we simply copy the event...
|
||||
event = ev;
|
||||
}
|
||||
|
||||
// fprintf(stderr, "event=%p!\n", event);
|
||||
|
||||
fl_lock_function();
|
||||
|
||||
fl_os_event = event;
|
||||
|
@ -817,6 +822,7 @@ static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler,
|
|||
GetEventParameter( event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &axis );
|
||||
long delta;
|
||||
GetEventParameter( event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(long), NULL, &delta );
|
||||
// fprintf(stderr, "axis=%d, delta=%d\n", axis, delta);
|
||||
if ( axis == kEventMouseWheelAxisX ) {
|
||||
Fl::e_dx = delta;
|
||||
if ( Fl::e_dx) Fl::handle( FL_MOUSEWHEEL, window );
|
||||
|
@ -1778,9 +1784,11 @@ void Fl_X::make(Fl_Window* w)
|
|||
OSStatus ret;
|
||||
EventHandlerUPP mousewheelHandler = NewEventHandlerUPP( carbonMousewheelHandler ); // will not be disposed by Carbon...
|
||||
static EventTypeSpec mousewheelEvents[] = {
|
||||
{ kEventClassMouse, 11 }, // "11" is the yet unlabled "MightyMouse" wheel event - sigh!
|
||||
// { kEventClassMouse, 11 }, // "11" is the yet unlabled "MightyMouse" wheel event - sigh!
|
||||
{ kEventClassMouse, kEventMouseWheelMoved } };
|
||||
ret = InstallWindowEventHandler( x->xid, mousewheelHandler, 2, mousewheelEvents, w, 0L );
|
||||
ret = InstallWindowEventHandler( x->xid, mousewheelHandler,
|
||||
(int)(sizeof(mousewheelEvents)/sizeof(mousewheelEvents[0])),
|
||||
mousewheelEvents, w, 0L );
|
||||
EventHandlerUPP mouseHandler = NewEventHandlerUPP( carbonMouseHandler ); // will not be disposed by Carbon...
|
||||
static EventTypeSpec mouseEvents[] = {
|
||||
{ kEventClassMouse, kEventMouseDown },
|
||||
|
|
|
@ -162,12 +162,12 @@ SudokuCell::handle(int event) {
|
|||
|
||||
case FL_KEYDOWN :
|
||||
int key = Fl::event_key() - '0';
|
||||
if (key >= 0 && key <= 9) {
|
||||
if (key > 0 && key <= 9) {
|
||||
if (Fl::event_state() & FL_SHIFT) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i ++) {
|
||||
if (!test_value_[i]) break;
|
||||
if (!test_value_[i] || test_value_[i] == key) break;
|
||||
}
|
||||
|
||||
if (i >= 4) {
|
||||
|
@ -182,7 +182,7 @@ SudokuCell::handle(int event) {
|
|||
do_callback();
|
||||
}
|
||||
return 1;
|
||||
} else if (Fl::event_key() == FL_BackSpace ||
|
||||
} else if (key == 0 || Fl::event_key() == FL_BackSpace ||
|
||||
Fl::event_key() == FL_Delete) {
|
||||
value(0);
|
||||
do_callback();
|
||||
|
|
Loading…
Reference in New Issue