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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Move Selection with keyboard

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
BionicWave Posted - Sep 13 2011 : 12:34:11
I want to move/alter a selection with Up/Down/Left/Right keys.
I used the OnSpecialKeys function with this:
img.select(img.selx1 + 1, img.sely1, img.selx2 + 1, img.sely2);

But it seems to not react in a very timely manner.

Is there another way to do this?
It also seems not to react as expected, cause the selection isnt moved by 1 pixel, but instead moved and same time croped by 1 pixel.
5   L A T E S T    R E P L I E S    (Newest First)
AndyColmes Posted - Sep 26 2011 : 18:35:42
Thanks William.
w2m Posted - Sep 21 2011 : 12:42:02
Try this to move object or selection:

procedure TFormMain.ImageEnVect1SpecialKey( Sender: TObject; CharCode: Word; Shift: TShiftState; var Handled: Boolean );
var
  i: integer;
begin
  // Is any object selected
  if ImageEnVect1.SelObjectsCount > 0 then
  begin
    // Move all selected objects
    for i := 0 to ImageEnVect1.SelObjectsCount - 1 do
    begin
      // if object(s) is/are selected move the object(s)
      if ImageEnVect1.IsSelObject( i ) then
      begin
        case CharCode of
          vk_Left:
            begin
              ImageEnVect1.ObjLeft[ i ] := ImageEnVect1.ObjLeft[ i ] - 1;
            end;
          vk_Down:
            begin
              ImageEnVect1.ObjTop[ i ] := ImageEnVect1.ObjTop[ i ] + 1;
            end;
          vk_Right:
            begin
              ImageEnVect1.ObjLeft[ i ] := ImageEnVect1.ObjLeft[ i ] + 1;
            end;
          vk_Up:
            begin
              ImageEnVect1.ObjTop[ i ] := ImageEnVect1.ObjTop[ i ] - 1;
            end;
        end; // case
        StatusBar1.Panels[ 0 ].Text := 'Left: ' + IntToStr( ImageEnVect1.ObjLeft[ 0 ] );
        StatusBar1.Panels[ 1 ].Text := 'Right: ' + IntToStr( ImageEnVect1.ObjLeft[ 0 ] + ImageEnVect1.ObjWidth[ 0 ] );
        StatusBar1.Panels[ 2 ].Text := 'Top: ' + IntToStr( ImageEnVect1.ObjTop[ 0 ] );
        StatusBar1.Panels[ 3 ].Text := 'Bottom: ' + IntToStr( ImageEnVect1.ObjTop[ 0 ] + ImageEnVect1.ObjHeight[ 0 ] );
        StatusBar1.Panels[ 4 ].Text := 'Width: ' + IntToStr( ImageEnVect1.ObjWidth[ 0 ] );
        StatusBar1.Panels[ 5 ].Text := 'Height: ' + IntToStr( ImageEnVect1.ObjHeight[ 0 ] );
      end;
    end;
  end // selected obj
  // else if selection move the selection
  else if ImageEnVect1.Selected then
  begin
    case CharCode of
      vk_Left:
        ImageEnVect1.MoveSelection( -1, 0 );
      vk_Down:
        ImageEnVect1.MoveSelection( 0, 1 );
      vk_Right:
        ImageEnVect1.MoveSelection( 1, 0 );
      vk_Up:
        ImageEnVect1.MoveSelection( 0, -1 );
    end;
    StatusBar1.Panels[ 0 ].Text := 'Left: ' + IntToStr( ImageEnVect1.SelX1 );
    StatusBar1.Panels[ 1 ].Text := 'Right: ' + IntToStr( ImageEnVect1.SelX2 );
    StatusBar1.Panels[ 2 ].Text := 'Top: ' + IntToStr( ImageEnVect1.SelY1 );
    StatusBar1.Panels[ 3 ].Text := 'Bottom: ' + IntToStr( ImageEnVect1.SelY2 );
    StatusBar1.Panels[ 4 ].Text := 'Width: ' + IntToStr( ImageEnVect1.SelX2 - ImageEnVect1.SelX1 );
    StatusBar1.Panels[ 5 ].Text := 'Height: ' + IntToStr( ImageEnVect1.SelY2 - ImageEnVect1.SelY1 );
  end;


William Miller
AndyColmes Posted - Sep 21 2011 : 10:11:00
How about moving an object in a TImageEnVect with the keyboard?
w2m Posted - Sep 19 2011 : 05:20:05
img.sex1 + 1, img.sel2 + 1, img.sely2); will not work.

Try this instead:

procedure TFormMain.ImageEnView1SpecialKey(Sender: TObject; CharCode: Word; Shift: TShiftState; var Handled: Boolean);
begin
   case CharCode of
    vk_Left:
      ImageEnView1.MoveSelection( -1, 0 );
    vk_Down:
      ImageEnView1.MoveSelection( 0, 1 );
    vk_Right:
      ImageEnView1.MoveSelection( 1, 0 );
    vk_Up:
      ImageEnView1.MoveSelection( 0, -1 );
  end;
end;


William Miller
fab Posted - Sep 15 2011 : 05:14:44
Select expects "client" coordinates (which depend on Zoom and Pan) unless the property SelectionBase is iesbBitmap.
Instead SelX1, SelY1, etc.. are relative to the bitmap (which do Not depend on Zoom and Pan).
For this reason you should set selection base to iesbBitmap:
img.SelectionBase := iesbBitmap;
img.Select(......);

iesbBitmap is defined in "imageenview" unit.

Finally please look also to the method MoveSelection.