dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

Pogu kombinācijas
Goto page 1, 2  Next
 
dev.gamez.lv Forum Index -> Iesācējiem
View previous topic :: View next topic  
Author Message
Moo



Joined: 13 Jan 2007
Posts: 42

PostPosted: Tue Jul 31, 2007 7:20 pm    Post subject: Pogu kombinācijas

^ Kā to var izdarīt? Piem ja VK_LSHIFT un (41) ir piespiestas tad kkas notiek. Iet runa par Delphi.

Paldies jau ieprieksh.
_________________
Moo
Back to top
View user's profile
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Tue Jul 31, 2007 10:44 pm    Post subject:

Kautkādā eventā (onKeyPress, onClick, onWhatever):
Code:
if VK_LSHIFT is pressed then left_shift := true;
if 41 is pressed then key_41 := true;
if (left_shift=true) and (key_41=true) then do_something!!!

Un kautkādā eventā (onKeyRelease):
Code:
if VK_LSHIFT is released then left_shift := false;
if 41 is released then key_41 := false;

Nav vienkārši?

Vēl var arī izmantot WinAPI funkciju GetAsyncKeyState (skat MSDNā).
Back to top
View user's profile Send e-mail
Moo



Joined: 13 Jan 2007
Posts: 42

PostPosted: Wed Aug 01, 2007 12:29 pm    Post subject:

Paldies, pārveidoju tā lai derētu. Bet (biki nūbisks jautājums Embarassed ) kā var nodeklarēt kko?
Quote:
[Pascal Error] Unit1.pas( 28 ): E2003 Undeclared identifier: 'left_shift'

zem var jāraksta? Ja jā, kādā formā tur jāietilpina left_shift?
_________________
Moo
Back to top
View user's profile
coderpp



Joined: 20 Aug 2005
Posts: 167
Location: Rīga, Koknese, Gajiena

PostPosted: Wed Aug 01, 2007 1:49 pm    Post subject:

Jā zem Var.
Code:

Var
left_shift:boolean;
Back to top
View user's profile Send e-mail
DeRatizators



Joined: 27 Apr 2006
Posts: 492

PostPosted: Wed Aug 01, 2007 2:02 pm    Post subject:

Sat Feb 17, 2007
Quote:
Es maacos delphi programeeshanu, pashus pamatus zinu ljoti labi


WTF !? Shocked Shocked Shocked
_________________
Any PANCAKE has to be long and thin and short and fat. Not to mention being an excellent insulator and a superb conductor.
Back to top
View user's profile
Moo



Joined: 13 Jan 2007
Posts: 42

PostPosted: Wed Aug 01, 2007 2:02 pm    Post subject:

Taatad, lai pameegjinaatu es uz "projekta" uzliku labelu. Kura saturam nospiezhot LSHIFT + A vajadzeetu mainiities uz Woof. Bet nekas nenotiek.
Code:
var
  Form1: TForm1;
  left_shift:boolean;
  key_41:boolean;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key = VK_LSHIFT then left_shift := true;
if key = 41 then key_41 := true;
if (left_shift=true) and (key_41=true) then begin
label1.Caption :=  'woof';
end;
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if key = VK_LSHIFT then left_shift := false;
if key = 41 then key_41 := false;
end;


EDIT: piekjeeri Twisted Evil
_________________
Moo
Back to top
View user's profile
coderpp



Joined: 20 Aug 2005
Posts: 167
Location: Rīga, Koknese, Gajiena

PostPosted: Wed Aug 01, 2007 2:37 pm    Post subject:

Pamēģini label1.update;
Back to top
View user's profile Send e-mail
Moo



Joined: 13 Jan 2007
Posts: 42

PostPosted: Wed Aug 01, 2007 2:47 pm    Post subject:

Neiet. Problēma laikam būs nevis ar label1, bet gan ar pogu kombināciju.
_________________
Moo
Back to top
View user's profile
coderpp



Joined: 20 Aug 2005
Posts: 167
Location: Rīga, Koknese, Gajiena

PostPosted: Wed Aug 01, 2007 3:11 pm    Post subject:

Code:
if key = #41 then key_41 := true;
Back to top
View user's profile Send e-mail
Moo



Joined: 13 Jan 2007
Posts: 42

PostPosted: Wed Aug 01, 2007 3:21 pm    Post subject:

Quote:
[Pascal Error] Unit1.pas(33): E2008 Incompatible types
[Pascal Error] Unit1.pas(42): E2008 Incompatible types

Grrr...
_________________
Moo
Back to top
View user's profile
coderpp



Joined: 20 Aug 2005
Posts: 167
Location: Rīga, Koknese, Gajiena

PostPosted: Wed Aug 01, 2007 3:31 pm    Post subject:

Ups! # būtu jaliek, ja key būtu char. Pamēģini label vietā likt ShowMessage('woof');
Back to top
View user's profile Send e-mail
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Wed Aug 01, 2007 3:33 pm    Post subject:

Vai Key šai OnKeyPress metodei tiešām padodās kā VK_LSHIFT un maģiskā konstante 41 ?
Back to top
View user's profile Send e-mail
coderpp



Joined: 20 Aug 2005
Posts: 167
Location: Rīga, Koknese, Gajiena

PostPosted: Wed Aug 01, 2007 3:53 pm    Post subject:

Code:

If ((GetKeyState(VK_LSHIFT) AND 128)=128) and ((GetKeyState(ord('a')) AND 128)=128) then
ShowMessage('SHIFT+A Pressed');
Back to top
View user's profile Send e-mail
Moo



Joined: 13 Jan 2007
Posts: 42

PostPosted: Wed Aug 01, 2007 3:53 pm    Post subject:

Es visu laiku izmantoju OnKeyDown un viss ko esmu meegjinaajis (iznjemot kombinācijas) ir strādājis. Esmu pashlaik meegjinaajis: visas bultinjas, space, delete poga. Pārbaudīju, uz OnKeyPress nedarbojas. Arī ne patstāvīgaas pogas

EDIiTe: Paarbaudiishu Coderpp doto variantu
EDIiTe2: Es kāds izredzētais? Nekas nenotiek Sad
_________________
Moo
Back to top
View user's profile
coderpp



Joined: 20 Aug 2005
Posts: 167
Location: Rīga, Koknese, Gajiena

PostPosted: Wed Aug 01, 2007 4:01 pm    Post subject:

Un kā tad tu pārējos taustiņus apstrādāji ar OnKeyDown?
Back to top
View user's profile Send e-mail
Display posts from previous:   
dev.gamez.lv Forum Index -> Iesācējiem All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group