Source language: Translate to:

Onclick Actions

Questions or information that don't quite fit anywhere else

Moderator: Neosoft Support

Onclick Actions

Postby SpiritHorseNOOT » Thu Jul 29, 2004 10:06 am

Can someone give me an example on how to assign a subroutine to an OnClick Action in Delphi

basically what i need is somehow to assign a subroutine to a Custom Object attached to a rectangle

(Edited by SpiritHorseNOOT at 1:20 pm on July 29, 2004)
SpiritHorseNOOT
 

Onclick Actions

Postby NeoSoft Support » Thu Jul 29, 2004 10:49 am

The plug-in SDK includes a procedure called nbPlayAction. All you need to do is pass the NeoBook action you want to execute to this procedure. For example, if you wanted to execute a subrotine called "MySub", your Delphi code would look like this:

nbPlayAction( PChar( 'GoSub "MySub"' ) );
NeoSoft Support
 

Onclick Actions

Postby HPW » Thu Jul 29, 2004 11:50 am

Taken from hpwImage:

TYPE ThpwImage = CLASS( TImage )
    PROTECTED
      PROCEDURE MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);OVERRIDE;





PROCEDURE ThpwImage.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  inherited; {Standardbehandlung mit Aufruf der Behandlungsroutine}

  IF Button = mbLeft THEN
  begin

code for left click here

  end;

  if Button = mbRight then
  begin

code for right click here

  end;

  if Button = mbMiddle then
  begin

code for middle click here

  end;
end;
HPW
 

Onclick Actions

Postby SpiritHorseNOOT » Thu Jul 29, 2004 2:56 pm

neosoft you might want to update the help file for the Plugin SDK cause

all references to

nbPlayAction


state that it should be formated like this

nbPlayAction('GoSub "MySub"' );
SpiritHorseNOOT
 

Onclick Actions

Postby Neosoft Support » Fri Jul 30, 2004 11:17 am

Both examples will work. Actually, you only need to typecast the parameter if it contains a string variable. For example:

SubroutineVar := 'MySub';
nbPlayAction( PChar( 'GoSub "'+SubroutineVar+'"' ) );
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Onclick Actions

Postby SpiritHorseNOOT » Fri Jul 30, 2004 2:28 pm

ok but how do i do something like this for example:


mybutton.onclick := nbPlayAction( PChar( 'GoSub "MySub"' ) );
SpiritHorseNOOT
 

Onclick Actions

Postby HPW » Sat Jul 31, 2004 12:16 am

I thought it was clear enough:

PROCEDURE ThpwImage.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
 inherited; {Standardbehandlung mit Aufruf der Behandlungsroutine}

 IF Button = mbLeft THEN
 begin
 nbPlayAction( PChar( 'GoSub "MySubLeft"' ) );
 end;

 if Button = mbRight then
 begin
 nbPlayAction( PChar( 'GoSub "MySubRight"' ) );
 end;

 if Button = mbMiddle then
 begin
 nbPlayAction( PChar( 'GoSub "MySubMiddle"' ) );
 end;
end;
HPW
 

Onclick Actions

Postby SpiritHorseNOOT » Sat Jul 31, 2004 1:00 am

yeah you was clear

but why do i have to create awholenother "Procedure" when the procedure is there for you

EX. ....  Mybutton.Onclick

is there away using the already existing procedure?


(Edited by SpiritHorseNOOT at 4:02 am on July 31, 2004)
SpiritHorseNOOT
 

Onclick Actions

Postby Alberto Meyer » Sat Jul 31, 2004 5:48 am

James, Are you using it inside a form? If yes, just put a button in the form, and, in the object inspector, click in the events tab.  In the events tab, you will see the OnClick event. Just click in it and put the NeoBook action that you want.
Alberto Meyer
 

Onclick Actions

Postby SpiritHorseNOOT » Sat Jul 31, 2004 9:17 am

no
SpiritHorseNOOT
 

Onclick Actions

Postby HPW » Sat Jul 31, 2004 12:56 pm

In your first post you have not mentioned that you try a button. My code was for a custom image component.

So when you place a button on a form and double-click on it it open the procedure for the button-click. There you put your code.
HPW
 

Onclick Actions

Postby SpiritHorseNOOT » Sat Jul 31, 2004 2:10 pm

no it ain't a form button

i am trying to avoid forms
SpiritHorseNOOT
 


Return to Misc. Questions and Information

Who is online

Users browsing this forum: No registered users and 1 guest

cron