ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 OnVirtualKey stuttering...
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
236 Posts

Posted - Feb 21 2013 :  03:48:14  Show Profile  Reply
Hi

I have an ImageEnView component with a number of layers I am stepping through to create an animation loop. I have actions for next frame and previous frame so I thought I would hook them up to the OnKeyDown event so that you could control them with the left/right arrow keys and the zoom level with the up/down arrow keys. This didn't work and I found that the component had a OnVirtualKey event. The code worked a lot more reliably with this - but I found when you stepped through one key press/frame at a time you got one successful event but the next event wouldn't fire. If you keep the key down the event fires repeatedly so all I can figure is that there is a repeat delay interval that's causing this. Can anyone advise me how I can smoothly loop through my frames one at a time?

procedure TfmMain.ImageVirtualKey(Sender: TObject; VirtualKey, KeyData: Cardinal; KeyDown: Boolean);
begin
  case VirtualKey of
    vk_add,vk_down    : TAzoomIn.Execute;
    vk_subtract,vk_up : TAzoomOut.Execute;
    vk_right          : TAnext.Execute;
    vk_left           : TAprevious.Execute;
  end;
end;


Bruce.

xequte

39140 Posts

Posted - Feb 21 2013 :  13:07:48  Show Profile  Reply
Hi

Did you try assigning these shortcuts to the "Shortcut" property of each TAction?

Failing that, OnKeyDown/Up would be the best place to do it. Was the event not firing? Did the ImageEnView lose focus?

You can also catch the OnKeyDown/Up events for the form if KeyPreview is enabled.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

bmesser

United Kingdom
236 Posts

Posted - Feb 22 2013 :  07:29:40  Show Profile  Reply
Nigel

You can't assign key events such as left & right arrow to actions as far as I know - only keys like insert or the function keys.

Anyway you where correct the image was losing focus somehow so I just added a line in the action to maintain the focus. Then the problem is even the shortest key press and the image layers looped at least two steps. So I added a 150 millisecond wait just before resetting the focus so it responded to a single key press. If you keep your finger down on the key it does auto-repeat.

Bruce.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: