InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IPageItemFocus Class Referenceabstract

#include <IPageItemFocus.h>

Inheritance diagram for IPageItemFocus:
IPMUnknown

Public Types

enum  { kDefaultIID = IID_IPAGEITEMFOCUS }
 

Public Member Functions

virtual void GrantPageItemFocus ()=0
 
virtual void RevokePageItemFocus ()=0
 
virtual bool16 IsPageItemFocused () const =0
 
virtual void SuspendPageItemFocus (bool16 bKeepVisible)=0
 
virtual void ResumePageItemFocus ()=0
 
virtual bool16 IsPageItemFocusSuspended () const =0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Detailed Description

PageItemFocus manages switches between page item event handling (PageItemEventHandler) and text event handling (FrameEventHandler). Page items and text selection have different event handlers: i.e. arrow key left moves a page item to the left on the spread if the PageItemEventHandler is active while the same key event moves the caret by one character to the left if the FrameEventHandler is activated. If the user switches from page item selection to text selection or vice versa the corresponding event handler needs to be registered as the current event handler. This is done via KeyFocusHandler::SetCurrentTargetEventHandler in three steps:

  • calling IEventHandler::GiveUpKeyFocus() on the current event handler.
  • replacing the current event handler with the new one.
  • calling IEventHandler::GetKeyFocus() on the new event handler.

There are several situations that require a change of event handlers and a call toKeyFocusHandler::SetCurrentTargetEventHandler:

  • Activation of TextSelection after creating a new TextFrame
  • Deactivation of TextSelection after switching to pointer tool.
  • Activation of TextSelection after clicking with pointer tool into TextFrame.

PageItemFocus offers a convenient API for activating and deactivating. PageItemFocus is implemented in PublicLib with kPageItemFocusImpl. It is only used by kStandOffBoss. FrameViewFocus is derived from PageItemFocus and is implemented in TextEditor with kFrameViewFocusImpl. It is only used by kTextEditorBoss:

  • kStandOffBoss uses kPageItemFocusImpl
  • kTextEditorBoss uses kFrameViewFocusImpl

This interface is part of the PageItem widget. It helps to differentiate between several cases of deactivation. Grant/RevokePageItemFocus is called, when the pageitem has the focus (i.e. if the user edits it). The selection would be visible and a TextCaret would blink. Suspend/ResumePageItemFocus is called when the window or the layout control view is deactivated. The selection would be shadowed, but a TextCaret would disappear.

These are possible cases for Grant/Revoke and Suspend/Resume: 1) Deactivate Window => Suspend( kTrue ) 2) Reactivate Window => Resume 3) Change the tool => Suspend( kFalse ) 4) Change back to the first tool => Resume 5) Close Document => Revoke 6) Create new PageItem => Grant 7) Place a story => Revoke 8) Change to an EditBox in a Panel => Suspend( kTrue )

Member Function Documentation

virtual void IPageItemFocus::GrantPageItemFocus ()
pure virtual

Grants a PageItem Focus. This method is called by anyone who thinks this PageItem should get the focus.

virtual bool16 IPageItemFocus::IsPageItemFocused () const
pure virtual

Returns whether a PageItem Focus has been granted.

Returns
the current focus state.
virtual bool16 IPageItemFocus::IsPageItemFocusSuspended () const
pure virtual

Returns whether a PageItem Focus has been suspended.

Returns
the current suspend state.
virtual void IPageItemFocus::ResumePageItemFocus ()
pure virtual

Suspends a PageItem Focus. This method resurrects the focus from the background.

virtual void IPageItemFocus::RevokePageItemFocus ()
pure virtual

Revokes a PageItem Focus. This method called by anyone who thinks this PageItem should lose the focus.

virtual void IPageItemFocus::SuspendPageItemFocus (bool16 bKeepVisible)
pure virtual

Suspends a PageItem Focus. This method keeps the focus but stays bKeepVisible in background.

Parameters
bKeepVisibleIN. Determines whether the focus should stay visible in the background or not.