diff --git a/B07_DesignDetail/openwebcad/src/helpers/keyboard-handler.ts b/B07_DesignDetail/openwebcad/src/helpers/keyboard-handler.ts index 1f69e423c..f9c9fb947 100644 --- a/B07_DesignDetail/openwebcad/src/helpers/keyboard-handler.ts +++ b/B07_DesignDetail/openwebcad/src/helpers/keyboard-handler.ts @@ -2,7 +2,7 @@ import type { KeyboardEvent } from 'react'; export function keyboardHandler(clickHandler: () => void) { return (evt: KeyboardEvent) => { - if (evt.key === 'Enter' || evt.key === 'Space') { + if (evt.key === 'Enter' || evt.key === ' ') { clickHandler(); } }; diff --git a/B07_DesignDetail/openwebcad/src/inputController/ime-sink.test.ts b/B07_DesignDetail/openwebcad/src/inputController/ime-sink.test.ts index 22ed47630..47feaa2a7 100644 --- a/B07_DesignDetail/openwebcad/src/inputController/ime-sink.test.ts +++ b/B07_DesignDetail/openwebcad/src/inputController/ime-sink.test.ts @@ -108,7 +108,7 @@ describe('Space = Enter(오토캐드)', () => { press(controller, 'a'); press(controller, ' '); press(controller, 'b'); - expect(textOf(controller)).toBe('A B'); + expect(textOf(controller)).toBe('a b'); expect(activeTool()).toBe(Tool.TEXT); }); diff --git a/B07_DesignDetail/openwebcad/src/inputController/input-controller.ts b/B07_DesignDetail/openwebcad/src/inputController/input-controller.ts index e74c7502c..dd3c6c21c 100644 --- a/B07_DesignDetail/openwebcad/src/inputController/input-controller.ts +++ b/B07_DesignDetail/openwebcad/src/inputController/input-controller.ts @@ -467,7 +467,8 @@ export class InputController { // +·-는 확대·축소 단축키로 쓰지 않는다 — 음수 좌표(-100,-50)의 첫 글자를 // 먹어 버렸다. 줌은 휠·뷰 막대·ZOOMIN/ZOOMOUT 명령으로 한다. // User entered a single character => add to input field text - this.text += evt.key.toUpperCase(); + // 글 단계(TEXT·MTEXT)는 친 그대로 — 명령 입력일 때만 대문자로 바꾼다. + this.text += activeToolWantsFreeText() ? evt.key : evt.key.toUpperCase(); } } diff --git a/B07_DesignDetail/openwebcad/src/tools/circle-tool.ts b/B07_DesignDetail/openwebcad/src/tools/circle-tool.ts index 716d881f2..cbd81db8f 100644 --- a/B07_DesignDetail/openwebcad/src/tools/circle-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/circle-tool.ts @@ -6,6 +6,7 @@ import { getActiveLineColor, getActiveLineDash, getActiveLineWidth, + setActiveToolActor, setAngleGuideOriginPoint, setGhostHelperEntities, setSelectedEntityIds, @@ -13,9 +14,10 @@ import { } from '../state'; import type { DrawEvent, PointInputEvent, StateEvent, ToolContext } from './tool.types'; import { Tool } from '../tools'; -import { assign, createMachine } from 'xstate'; +import { Actor, assign, createMachine } from 'xstate'; import { pointDistance } from '../helpers/distance-between-points'; import { LineState } from './line-tool.ts'; +import { selectToolStateMachine } from './select-tool.ts'; import { getPointFromEvent } from '../helpers/get-point-from-event.ts'; export interface CircleContext extends ToolContext { @@ -33,6 +35,7 @@ export enum CircleAction { RECORD_START_POINT = 'RECORD_START_POINT', DRAW_TEMP_CIRCLE = 'DRAW_TEMP_CIRCLE', DRAW_FINAL_CIRCLE = 'DRAW_FINAL_CIRCLE', + SWITCH_TO_SELECT_TOOL = 'SWITCH_TO_SELECT_TOOL', } export const circleToolStateMachine = createMachine( @@ -68,6 +71,9 @@ export const circleToolStateMachine = createMachine( actions: CircleAction.RECORD_START_POINT, target: CircleState.WAITING_FOR_POINT_ON_CIRCLE, }, + ESC: { + actions: CircleAction.SWITCH_TO_SELECT_TOOL, + }, }, }, [CircleState.WAITING_FOR_POINT_ON_CIRCLE]: { @@ -159,6 +165,9 @@ export const circleToolStateMachine = createMachine( centerPoint: null, }; }), + [CircleAction.SWITCH_TO_SELECT_TOOL]: () => { + setActiveToolActor(new Actor(selectToolStateMachine)); + }, }, } );