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
 Move Selection with keyboard
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

BionicWave

Germany
33 Posts

Posted - Sep 13 2011 :  12:34:11  Show Profile  Reply
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.

fab

1310 Posts

Posted - Sep 15 2011 :  05:14:44  Show Profile  Reply
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.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 19 2011 :  05:20:05  Show Profile  Reply
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
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Sep 21 2011 :  10:11:00  Show Profile  Reply
How about moving an object in a TImageEnVect with the keyboard?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Sep 21 2011 :  12:42:02  Show Profile  Reply
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
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Sep 26 2011 :  18:35:42  Show Profile  Reply
Thanks William.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: