Palette Questions

Started by Kerry, December 07, 2009, 08:07:15 PM

Previous topic - Next topic

Kerry

With Build 6.0.0.15
with Ac2010

The Palette is described as
QuoteThe palette form displays a modeless dialog that can either remain floating or be docked to the AutoCAD window. Palettes have a vertical title bar, and feature the ability to collapse and expand automatically in response to cursor movement.

How do I get the palette to collapse and 'expand automatically in response to cursor movement.'
ie how do I hide the Palette when the mouse is not on it?

With the  Palette NOT docked :
Then when I select the Auto-Hide icon on the vertical bar, the palette will close and show manually.
The Auti-Hide toggle accessed from right click on the Vertical bar seems to have no affect


With the  Palette  docked :
Then when I select the Auto-Hide icon on the vertical bar, the palette become Un-docked.

Code (autolisp) Select


(vl-load-com)
(command "OPENDCL")

;;(if (not (vl-symbol-value 'kglobal:librarybuild))
;;  (load "KDUB_LIBRARY.VLX")
;;)
;;;---------------------------------------------------------------------------
;;;
;; (findfile "Pal.ODCL")

;|<<MAIN>>|;

(defun c:pal (/ dialogreturn)
 ;; (dcl_project_load "Pal.ODCL" t)
 (dcl_project_load "Pal.ODCL")
 ;; Show the main form  
 (setq dialogreturn (dcl_form_show Pal_main))
 ;;------  
 (princ)
)

;;;---------------------------------------------------------------------------
;;;
;|<<SUPPORT>>|;

;;;---------------------------------------------------------------------------
;;;
;|<<OPENDCL Handlers Event>>|;

;;;-------------------------------------------
;|
This event is triggered immediately before the dialog is closed.
UpperLeftX, UpperLeftY is the coordinate of the upper left corner of the dialog.
|;
(defun c:Pal_Main_OnClose (UpperLeftX UpperLeftY /)
 (dcl_MessageBox "To Do: code must be added to event handler\r\nc:Pal_Main_OnClose" "To do")
)
;;;-------------------------------------------
;|
The OnInitialize event is called immediately before a form is shown on the screen.
This event handler can initialize the form and its controls before they are displayed.
|;
(defun c:Pal_Main_OnInitialize (/)
 ;; (dcl_MessageBox "To Do: code must be added to event handler\r\nc:Pal_Main_OnInitialize" "To do")
 (dcl_Control_SetCaption Pal_Main_Label1 (getvar "DWGNAME"))
 (princ)
)
;;;-------------------------------------------
;|
This event is triggered when the user closes the last open AutoCAD drawing.
If any of the modeless dialog's controls are dependent on the state or contents of the current drawing file,
they should be cleared at this time. Once the drawing is closed, no AutoLISP code can execute since there
is no document context for it to execute in.
This event handler will be the last opportunity to execute code until a new document is opened.
|;
(defun c:Pal_Main_OnEnteringNoDocState (/)
 (if (dcl_Form_IsActive Pap)
   (dcl_form_close Pal)
 )
)

;;;-------------------------------------------
;|
This event is triggered when the user switches to a different open AutoCAD drawing.
Note that opening a new drawing will not trigger any event. An application that uses modeless dialogs
must be installed so that its code is loaded into each newly created drawing document,
and the application's initialization code must check for already active dialogs that it must manage.
|;
(defun c:Pal_Main_OnDocActivated (/)
 (dcl_MessageBox "To Do: code must be added to event handler\r\nc:Pal_Main_OnDocActivated" "To do")
)
;;;---------------------------------------------------------------------------
;;;
Attached is the ODCL I'm using:

Perfection is not optional.
My other home is TheSwamp

Fred Tomke

Hi, Kerry, a very interesting question and a very easy answer:
The palette has a property KeepFocus. It must be set to false. Otherwise autocollapse won't work (because the form keeps always the focus).
I solved this by using OnMouseEntered and OnMouseOff events from the palette form to Change the KeepFocus value.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Kerry


Thanks fred,
I had a scribble note to try that in the morning ... great to know I have a workable option.

I'll bookmark this for a possible series of tutorials on palettes (when I make time)

Regards
Kerry
Perfection is not optional.
My other home is TheSwamp

velasquez

Hi, Fred, 
Can you post an example of how this works?

Regards
Velasquez

owenwengerd

Fred, in what way is your solution different than just leaving KeepFocus set to false?
Owen Wengerd (Outside The Box) / ManuSoft

Kerry


Owen,
If KeepFocus set to false, we are unable to enter text into the TextBox ... the keystrokes are diverted to the commandLine.
Perfection is not optional.
My other home is TheSwamp

owenwengerd

Quote from: Kerry Brown on December 08, 2009, 04:06:22 PM
If KeepFocus set to false, we are unable to enter text into the TextBox ... the keystrokes are diverted to the commandLine.

That should only be the case if the mouse leaves the palette.  If I understand Fred's solution, it would have the same problem.
Owen Wengerd (Outside The Box) / ManuSoft

Kerry

no, not the case. the docs are correct
QuoteIf this property is False, controls on the form do not keep the keyboard input focus; all keyboard input is sent to the AutoCAD command line instead. Set this property to True when a form contains controls that accept keyboard input.
Perfection is not optional.
My other home is TheSwamp

Kerry

#8
Quote from: velasquez on December 08, 2009, 10:23:53 AM
< .. >
Can you post an example of how this works?

Regards
Velasquez

Velasquez,
This is VERY basic

manually set the Auto-hide property at Right-Click on the Palette Vertical TitleBar

Kerry

code attached:
Perfection is not optional.
My other home is TheSwamp

velasquez

Thanks, Kerry


Regards
Velasquez

owenwengerd

Kerry, did you get this resolved?  Should there be a change made to the way the keepfocus property works so that the workaround isn't necessary? Or said another way, is there any good reason *not* to change it?
Owen Wengerd (Outside The Box) / ManuSoft

Kerry


The OnMouseEntered and OnMouseOff events fire a lot .. very busy .
I'm happy with the current method ... but I'll have a think about any changes.
I imagine any changes will have ramifications elsewhere and to existing code, ... thats a good reason not to change I 'spose :)
Perfection is not optional.
My other home is TheSwamp

Kerry


Owen
I've been testing some Palettes .. build 6.0.0.18
The MouseEntered MouseMovedOff Events don't seem to be needed to let the Palette AutoHide .. Has this changed recently ??  :)
Works great !!!


Fred's FAQ sample may need to be changed.
Perfection is not optional.
My other home is TheSwamp

Fred Tomke

Hi, haven't tested yet.

Quote from: Kerry Brown on January 06, 2010, 12:51:16 AM
Fred's FAQ sample may need to be changed.

In that case I'd rather delete this FAQ unless it is needed for other cases...

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

Hmm, I don't recall intentionally changing anything.
Owen Wengerd (Outside The Box) / ManuSoft