Skip to content

Commit

Permalink
Right mouse click on card will open item menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kisspeace committed Jul 2, 2023
1 parent 44475d1 commit cd7c4ac
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions source/Unit1.pas
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ TForm1 = class(TForm)
procedure BtnSetChangeDownloadAllModeOnTap(Sender: TObject; const Point: TPointF);
procedure BtnSetSaveOnItemTapOnTap(Sender: TObject; const Point: TPointF);
procedure SettingsCheckOnTap(Sender: TObject; const Point: TPointF);
procedure CardOnTap(Sender: TObject; const Point: TPointF);
procedure IconOnResize(Sender: TObject);
procedure BookmarksControlOnTap(Sender: TObject; const Point: TPointF);
procedure MenuChangeThemeOnSelected(Sender: TObject);
Expand Down Expand Up @@ -404,6 +403,8 @@ TForm1 = class(TForm)
procedure OnNewItem(Sender: TObject; var AItem: TNBoxCardBase);
procedure OnSimpleCardResize(Sender: TObject);
procedure OnCardAutoLook(Sender: TObject);
procedure CardOnTap(Sender: TObject; const Point: TPointF);
procedure CardOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
{ ----------------------------- }
procedure SaveSettings;
procedure SaveSettingsChanges;
Expand Down Expand Up @@ -4054,6 +4055,7 @@ procedure TForm1.OnNewItem(Sender: TObject; var AItem: TNBoxCardBase);
with AItem do begin
OnTap := CardOnTap;
OnAutoLook := OnCardAutoLook;
OnMouseDown := CardOnMouseDown;
AppStyle.ItemCard.Apply(AItem);

if AItem is TNBoxCardSimple then
Expand Down Expand Up @@ -4108,21 +4110,37 @@ function TForm1.IndexTabByBrowser(ABrowser: TNBoxBrowser): integer;
end;
end;

procedure DefaultAfterClick(ACard: TNBoxCardBase);
begin
if ACard.HasPost then
begin
Form1.CurrentItemForWaitFetch := Form1.FetchContent(ACard.Post);
if Form1.Settings.SaveTapHistory then
HistoryDb.TapGroup.Add(ACard.Post);
end;
end;

procedure TForm1.CardOnMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
var
LItem: TNBoxCardBase;
begin
if Button = TMouseButton.mbRight then
begin
LItem := Sender as TNBoxCardBase;
DefaultAfterClick(LItem);
ExecItemInteraction(LItem, ACTION_OPEN_MENU);
end;
end;

procedure TForm1.CardOnTap(Sender: TObject; const Point: TPointF);
var
I: integer;
Item: TNBoxCardBase;
Interactions: TArray<NativeInt>;
begin
Item := ( Sender as TNBoxCardBase );

if Item.HasPost then
begin
CurrentItemForWaitFetch := FetchContent(Item.Post);
if Settings.SaveTapHistory then
HistoryDb.TapGroup.Add(Item.Post);
end;

Item := (Sender as TNBoxCardBase);
DefaultAfterClick(Item);
Interactions := Settings.ItemInteractions;
for I := 0 to High(Interactions) do
begin
Expand Down

0 comments on commit cd7c4ac

Please sign in to comment.