332 ! ! |
332 ! ! |
333 |
333 |
334 !EnterFieldGroup methodsFor:'adding / removing'! |
334 !EnterFieldGroup methodsFor:'adding / removing'! |
335 |
335 |
336 add:aField |
336 add:aField |
337 |thisIndex next action| |
337 |thisIndex action| |
338 |
338 |
339 fields isNil ifTrue:[ |
339 fields isNil ifTrue:[ |
340 fields := OrderedCollection new |
340 fields := OrderedCollection new |
341 ]. |
341 ]. |
342 fields add:aField. |
342 fields add:aField. |
343 thisIndex := fields size. |
343 thisIndex := fields size. |
344 |
344 |
345 aField delegate:self. |
345 aField delegate:self. |
346 aField hideCursor. |
346 aField hideCursor. |
347 aField disable. |
347 aField disable. |
348 |
348 |
349 "set the fields enableAction to disable active field" |
349 "set the fields enableAction to disable active field" |
350 |
350 |
351 aField enableAction:[ |
351 aField clickAction:[:field | |
352 "/ Transcript showCr:'enable field with: ' , aField editValue. |
352 self makeActive:field |
|
353 ]. |
|
354 |
|
355 "set the fields leaveAction to enable next field" |
|
356 |
|
357 aField leaveAction:[:key | |
|
358 |next wg explicit nFields nextField| |
|
359 |
353 "/ currentField notNil ifTrue:[ |
360 "/ currentField notNil ifTrue:[ |
354 "/ currentField disable |
361 "/ currentField disable. |
|
362 "/ currentField hideCursor. |
355 "/ ]. |
363 "/ ]. |
356 "/ currentField := aField |
364 "/ |
357 self makeActive:aField |
365 action := key. |
|
366 nFields := fields size. |
|
367 |
|
368 ((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[ |
|
369 (thisIndex == 1) ifTrue:[ |
|
370 next := nFields |
|
371 ] ifFalse:[ |
|
372 next := thisIndex - 1 |
|
373 ] |
|
374 ]. |
|
375 ((key == #CursorDown) |
|
376 or:[key == #NextField |
|
377 or:[key == #Tab]]) ifTrue:[ |
|
378 (thisIndex == nFields) ifTrue:[ |
|
379 next := 1. |
|
380 wrap == false ifTrue:[ |
|
381 action := #Return. |
|
382 ]. |
|
383 ] ifFalse:[ |
|
384 next := thisIndex + 1 |
|
385 ] |
|
386 ]. |
|
387 (action == #Return) ifTrue:[ |
|
388 (thisIndex == nFields) ifTrue:[ |
|
389 leaveAction notNil ifTrue:[ |
|
390 currentField := nil. |
|
391 leaveAction value. |
|
392 next := nil |
|
393 ] ifFalse:[ |
|
394 next := 1 |
|
395 ] |
|
396 ] ifFalse:[ |
|
397 next := thisIndex + 1 |
|
398 ] |
|
399 ]. |
|
400 next notNil ifTrue:[ |
|
401 nextField := fields at:next. |
|
402 |
|
403 explicit := false. |
|
404 (wg := currentField windowGroup) notNil ifTrue:[ |
|
405 wg focusView == currentField ifTrue:[ |
|
406 explicit := true. |
|
407 ] |
|
408 ]. |
|
409 explicit ifTrue:[ |
|
410 wg focusView:nextField. |
|
411 ] ifFalse:[ |
|
412 self makeActive:nextField |
|
413 ] |
|
414 ] |
358 ]. |
415 ]. |
359 |
416 |
360 "set the fields leaveAction to enable next field" |
|
361 |
|
362 aField leaveAction:[:key | |
|
363 "/ Transcript showCr:'left field with: ' , aField editValue. |
|
364 currentField notNil ifTrue:[ |
|
365 currentField disable. |
|
366 currentField hideCursor. |
|
367 ]. |
|
368 |
|
369 action := key. |
|
370 ((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[ |
|
371 (thisIndex == 1) ifTrue:[ |
|
372 next := fields size |
|
373 ] ifFalse:[ |
|
374 next := thisIndex - 1 |
|
375 ] |
|
376 ]. |
|
377 ((key == #CursorDown) |
|
378 or:[key == #NextField |
|
379 or:[key == #Tab]]) ifTrue:[ |
|
380 (thisIndex == (fields size)) ifTrue:[ |
|
381 next := 1. |
|
382 wrap == false ifTrue:[ |
|
383 action := #Return. |
|
384 ]. |
|
385 ] ifFalse:[ |
|
386 next := thisIndex + 1 |
|
387 ] |
|
388 ]. |
|
389 (action == #Return) ifTrue:[ |
|
390 (thisIndex == (fields size)) ifTrue:[ |
|
391 leaveAction notNil ifTrue:[ |
|
392 currentField := nil. |
|
393 leaveAction value. |
|
394 next := nil |
|
395 ] ifFalse:[ |
|
396 next := 1 |
|
397 ] |
|
398 ] ifFalse:[ |
|
399 next := thisIndex + 1 |
|
400 ] |
|
401 ]. |
|
402 next notNil ifTrue:[ |
|
403 self makeActive:(fields at:next) |
|
404 ] |
|
405 ]. |
|
406 |
|
407 fields size == 1 ifTrue:[ |
417 fields size == 1 ifTrue:[ |
408 "the first one" |
418 "the first one" |
409 self makeActive:aField |
419 self makeActive:aField |
410 ] |
420 ] |
411 ! ! |
421 ! ! |
412 |
422 |
413 !EnterFieldGroup methodsFor:'event forwarding'! |
423 !EnterFieldGroup methodsFor:'event forwarding'! |
414 |
424 |
458 "key-press in any field - forward the key to the active field |
468 "key-press in any field - forward the key to the active field |
459 (with -1/-1 as coordinate to indicate that the key was pressed |
469 (with -1/-1 as coordinate to indicate that the key was pressed |
460 outside. However, this info is not used by any view currently)" |
470 outside. However, this info is not used by any view currently)" |
461 |
471 |
462 currentField notNil ifTrue:[ |
472 currentField notNil ifTrue:[ |
463 currentField keyPress:key x:-1 y:-1 |
473 currentField keyPress:key x:-1 y:-1 |
464 ] |
474 ] |
465 ! |
475 ! |
466 |
476 |
467 keyRelease:key x:x y:y view:aView |
477 keyRelease:key x:x y:y view:aView |
468 "key-release in any field - forward the key to the active field. |
478 "key-release in any field - forward the key to the active field. |