現在地: Visual LANSA 開発者ガイド > 2. グラフィカル・ユーザーインターフェース・アプリケーションの作成 > 2.25 ヘルプ・テキストとドキュメント・コンポーネント > 2.25.2 iHelpHandlerインターフェース

2.25.2 iHelpHandlerインターフェース

HelpHandlerインターフェースを使用すると、独立した(リポジトリに保存されない)ヘルプを柔軟に作成できます。

iHelpHandlerインターフェースの使用では、ヘルプ・メカニズムを実装するオプションがあります。適切なコードを挿入するだけで、ヘルプは、特定のコンポーネントでヘルプが要求されたことの通知を送信するメカニズムから送信されます。この後どうするかは、すべてを自分で決定します。

この例では、フォームはiHelpHandlerインターフェースを実装します。F1が押されると、フォーカスが置かれているコンポーネントはヘルプ・インターフェースを実装しているかどうかを判断します。実装していない場合は、ヘルプは通常の自動化されたリポジトリ・ヘルプから処理されます。実装している場合、ProcessHelpRequestメソッドが実行されます。

以下のコードは、現在フォーカスが置かれているコントロールの参照を受け取るFind_Tagメソッドです。例では、要求しているコンポーネントのComponentTagプロパティを使用して表示するヘルプを判断します。ComponentTagがブランクの場合は、メソッドのHandledはfalseになり、LANSAに通常の方法でヘルプを表示することを通知します。ただし、ComponentTagがブランクでない場合は、メッセージ・ボックスが表示されます。制御がメッセージ・ボックスからフォームに返されると、HandledはTrueに設定され、通常のリポジトリ・ヘルプは表示されません。

この例は、RDMLXを使用します。

Mthroutine Name(Find_Tag) Help('Find a tag for the current control.Use Parent chain to resolve if none specified') Access(*Private)
Define_Map For(*Input) Class(#prim_objt) Name(#i_Requestor) Pass(*by_reference)
Define_Map For(*Result) Class(#prim_alph) Name(#o_tag)
 
* If a control is supplied
If ((#i_Requestor *IsNot *null) *AndIf (#i_requestor *Is #prim_ctrl))
 
* If the Control has a tag, use it, otherwise go up the parent chain, and try again
If (#i_Requestor.ComponentTag <> '')
 
#o_tag := #i_Requestor.ComponentTag
 
Else
 
If (#i_Requestor.Parent *Is #prim_ctrl)
 
* Look for a tag in the parent
#o_tag := #com_owner.Find_tag( #i_Requestor.Parent )
 
Else
 
* If not control supplied, use a default
#o_tag := 'DefaultTag'
 
Endif
 
Endif
 
Else
 
* If not control supplied, use a default
#o_tag := 'DefaultTag'
 
Endif
 
Endroutine 

 

ProcessHelpRequestメソッドが実行されると、アプリケーションを完全に制御できます。タグがブランクのタグの場合に、通常のリポジトリ・ヘルプを使用せず、親階層内でタグを持つコントロールを探すことができます。このように、単純なrecursiveメソッドでは、一連の複雑な再利用可能パーツ内にフォーカスが置かれていてもヘルプ・タグを提供できます。例のFind_Tagメソッドは、この技術を示しています。

ヘルプのこの方法をアプリケーションで採用する場合は、すべてのフォームと再利用可能パーツで実装することが必要です。この処理をすべての他のコンポーネント継承する基本クラスのフォームと再利用可能パーツで実装することをお勧めします。

iHelpHandlerコードの例

Function Options(*DIRECT)

Begin_Com Role(*EXTENDS #PRIM_FORM *implements #Prim_App.IHelpHandler) Clientheight(306) Clientwidth(416) Componenttag('Help for the form') Left(91) Top(134) Width(424)
Define_Com Class(#Std_num.Visual) Name(#Std_num) Componenttag('Standard_Number') Displayposition(1) Height(19) Left(8) Parent(#COM_OWNER) Tabposition(1) Top(8) Usepicklist(False) Width(262)
Define_Com Class(#Std_texts.Visual) Name(#Std_texts) Componenttag('Standard_Text_Short') Displayposition(2) Height(19) Left(8) Parent(#COM_OWNER) Tabposition(2) Top(32) Usepicklist(False) Width(401)
Define_Com Class(#Empno.Visual) Name(#Empno) Displayposition(3) Left(8) Parent(#COM_OWNER) Tabposition(3) Top(56) Width(232)
 
Mthroutine Name(ProcessHelpRequest) Options(*Redefine)
* Define_Map For(*input) Class(#prim_objt) Name(#Requestor) Pass(*by_reference)
* Define_Map For(*input) Class(#prim_boln) Name(#Handled)
 
#Handled := False
 
If (#Requestor *IsNot *null)
 
* If the requesting component has a Tag, interrupt the help and use the user defined help.
If (#requestor.ComponentTag <> "")
 
* Show Help for the requesting control
#Com_owner.Show_help( #Requestor )
 
* Set the Handled flag.If not set to true, normal Repository help will be displayed
#Handled := True
 
Endif
 
Endif
 
Endroutine
 
Mthroutine Name(Show_Help)
Define_Map For(*input) Class(#Prim_Objt) Name(#Requestor) Pass(*by_reference)
 
* This example simply displays the Component tag property of the requesting control
* However, the developer is now in full control of the help request, and can show help as they require 
Use Builtin(Message_Box_Show) With_Args(Ok OK Information 'Help' #requestor.ComponentTag)
 
Endroutine
 
End_Com