X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=KeySetting.pas;h=eb1adf399d5dd3522a22652886cd6764d942d64d;hb=refs%2Fheads%2FBb62;hp=25217a189e06d13da5660ce2192912c814e4147e;hpb=ec31f4f9b3264b3422588a297caaf448edb5489a;p=gikonavigoeson%2Fgikonavi.git diff --git a/KeySetting.pas b/KeySetting.pas index 25217a1..eb1adf3 100644 --- a/KeySetting.pas +++ b/KeySetting.pas @@ -4,8 +4,8 @@ interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, GikoSystem, GikoUtil, - Editor; + Dialogs, ComCtrls, StdCtrls, ExtCtrls, ActnList, Menus, + Editor; type TKeySettingItem = class(TObject) @@ -57,11 +57,14 @@ type procedure OnGestureMove(Sender: TObject); procedure OnGestureEnd(Sender: TObject); procedure GestureCheckBoxClick(Sender: TObject); + procedure GestureEditChange(Sender: TObject); + procedure GestureEditKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); private { Private éŒ¾ } public { Public éŒ¾ } - EditorForm: TEditorForm; + EditorForm: TEditorForm; end; //var @@ -69,7 +72,11 @@ type implementation -uses Giko, Gesture; +uses + Giko, GikoUtil, Gesture, GikoDataModule, GikoSystem; + +const + GUESTURE_NOTHING = '‚È‚µ'; {$R *.dfm} @@ -80,29 +87,30 @@ var KeyItem: TKeySettingItem; begin - for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin - if GikoForm.ActionList.Actions[i] is TAction then begin - if GikoForm.ActionList.Actions[i].Tag <> 0 then + //for i := 0 to GikoForm.ActionList.ActionCount - 1 do begin + for i := 0 to GikoDM.GikoFormActionList.ActionCount - 1 do begin + //if GikoForm.ActionList.Actions[i] is TAction then begin + if GikoDM.GikoFormActionList.Actions[i] is TAction then begin + if GikoDM.GikoFormActionList.Actions[i].Tag <> 0 then Continue; ListItem := ListView.Items.Add; - ListItem.Caption := TAction(GikoForm.ActionList.Actions[i]).Hint; - ListItem.SubItems.Add(TAction(GikoForm.ActionList.Actions[i]).Category); - ListItem.SubItems.Add(ShortCutToText(TAction(GikoForm.ActionList.Actions[i]).ShortCut)); + ListItem.Caption := TAction(GikoDM.GikoFormActionList.Actions[i]).Hint; + ListItem.SubItems.Add(TAction(GikoDM.GikoFormActionList.Actions[i]).Category); + ListItem.SubItems.Add(ShortCutToText(TAction(GikoDM.GikoFormActionList.Actions[i]).ShortCut)); ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture( - TAction( GikoForm.ActionList.Actions[i] ) ) ); - ListItem.ImageIndex := TAction(GikoForm.ActionList.Actions[i]).ImageIndex; + TAction( GikoDM.GikoFormActionList.Actions[i] ) ) ); + ListItem.ImageIndex := TAction(GikoDM.GikoFormActionList.Actions[i]).ImageIndex; KeyItem := TKeySettingItem.Create; - KeyItem.Action := TAction(GikoForm.ActionList.Actions[i]); - KeyItem.ShortCut := TAction(GikoForm.ActionList.Actions[i]).ShortCut; + KeyItem.Action := TAction(GikoDM.GikoFormActionList.Actions[i]); + KeyItem.ShortCut := TAction(GikoDM.GikoFormActionList.Actions[i]).ShortCut; KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture( - TAction( GikoForm.ActionList.Actions[i] ) ); + TAction( GikoDM.GikoFormActionList.Actions[i] ) ); ListItem.Data := KeyItem; end; end; if ListView.Items.Count > 0 then ListView.Selected := ListView.Items[0]; EditorForm := TEditorForm.Create(Self); - GikoSys.LoadEditorKeySetting(EditorForm.ActionList); try for i := 0 to EditorForm.ActionList.ActionCount - 1 do begin if EditorForm.ActionList.Actions[i] is TAction then begin @@ -114,12 +122,12 @@ begin ListItem.SubItems.Add(ShortCutToText(TAction(EditorForm.ActionList.Actions[i]).ShortCut)); ListItem.ImageIndex := TAction(EditorForm.ActionList.Actions[i]).ImageIndex; ListItem.SubItems.Add( GikoSys.Setting.Gestures.GetActionGesture( - TAction( GikoForm.ActionList.Actions[i] ) ) ); + TAction( EditorForm.ActionList.Actions[i] ) ) ); KeyItem := TKeySettingItem.Create; KeyItem.Action := TAction(EditorForm.ActionList.Actions[i]); KeyItem.ShortCut := TAction(EditorForm.ActionList.Actions[i]).ShortCut; KeyItem.Gesture := GikoSys.Setting.Gestures.GetActionGesture( - TAction( GikoForm.ActionList.Actions[i] ) ); + TAction( EditorForm.ActionList.Actions[i] ) ); ListItem.Data := KeyItem; end; end; @@ -166,6 +174,7 @@ begin if TObject(Item.Data) is TKeySettingItem then begin KeyItem := TKeySettingItem(Item.Data); HotKey.HotKey := KeyItem.ShortCut; + GestureEdit.Text := KeyItem.Gesture; end; end; @@ -279,10 +288,11 @@ const ERR_MSG = '“ü—Í‚µ‚½ƒWƒFƒXƒ`ƒƒ[‚ÍŠù‚ÉŽg—p‚³‚ê‚Ä‚¢‚Ü‚·'; ERR_TITLE = 'ƒGƒ‰['; var - i: Integer; + i, j: Integer; Item: TListItem; KeyItem: TKeySettingItem; ActiveListView: TListView; + chechList : TListView; begin if PageControl1.ActivePage.TabIndex <> 0 then ActiveListView := ListView1 @@ -292,28 +302,46 @@ begin if ActiveListView.Selected = nil then Exit; if (GetKeyState( VK_SHIFT ) and $80000000) <> 0 then begin GestureEdit.Text := ''; + Item := ActiveListView.Selected; + Item.SubItems[2] := ''; + if TObject(Item.Data) is TKeySettingItem then begin + KeyItem := TKeySettingItem(Item.Data); + KeyItem.Gesture := ''; + end; Exit; end; // Œ»Ý‘I‘ð‚³‚ê‚Ä‚¢‚éActionˆÈŠO‚Å“¯‚¶ƒWƒFƒXƒ`ƒƒ[‚ª‚ ‚ê‚΃Gƒ‰[‚Æ‚·‚é - for i := 0 to ActiveListView.Items.Count - 1 do begin - if ActiveListView.Selected = ActiveListView.Items[i] then - Continue; - Item := ActiveListView.Items[i]; - if TObject(Item.Data) is TKeySettingItem then begin - KeyItem := TKeySettingItem(Item.Data); - if KeyItem.Gesture = GestureEdit.Text then begin - MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP); - HotKey.SetFocus; - Exit; + chechList := ListView; + for j := 0 to 1 do begin + if j <> 0 then begin + chechList := ListView1; + end; + + for i := 0 to chechList.Items.Count - 1 do begin + if ActiveListView.Selected = chechList.Items[i] then + Continue; + Item := chechList.Items[i]; + if TObject(Item.Data) is TKeySettingItem then begin + KeyItem := TKeySettingItem(Item.Data); + if (GestureEdit.Text <> GUESTURE_NOTHING) + and (KeyItem.Gesture = GestureEdit.Text) then begin + MsgBox(Handle, ERR_MSG, ERR_TITLE, MB_OK or MB_ICONSTOP); + HotKey.SetFocus; + Exit; + end; end; end; end; + // ƒWƒFƒXƒ`ƒƒ[Ý’è if TObject(ActiveListView.Selected.Data) is TKeySettingItem then begin KeyItem := TKeySettingItem(ActiveListView.Selected.Data); KeyItem.Gesture := GestureEdit.Text; - ActiveListView.Selected.SubItems[2] := GestureEdit.Text; + if GestureEdit.Text = GUESTURE_NOTHING then + ActiveListView.Selected.SubItems[2] := '' + else + ActiveListView.Selected.SubItems[2] := GestureEdit.Text; end; end; @@ -330,6 +358,7 @@ end; procedure TKeySettingForm.OnGestureEnd(Sender: TObject); begin GestureEdit.Text := MouseGesture.GetGestureStr; + MouseGesture.Clear; end; procedure TKeySettingForm.GestureCheckBoxClick(Sender: TObject); @@ -338,4 +367,19 @@ begin GestureSetButton.Enabled := GestureCheckBox.Checked; end; +procedure TKeySettingForm.GestureEditChange(Sender: TObject); +begin + + if GestureEdit.Text = '' then + GestureEdit.Text := GUESTURE_NOTHING; + +end; + +procedure TKeySettingForm.GestureEditKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +begin + if (ssShift in Shift) and (MouseGesture.GetGestureStr = '') then + GestureEdit.Text := ''; +end; + end.