I'm having some trouble writing a control and hope somebody more experienced
can point me in the right direction.
When a key is pressed while focus is on a standard lisbox view, the listbox's
current-item is changed to be the next item that starts with the character
typed. I'm trying to write a wrapper control that will allow customizing this
behaviour. What I have in mind is a new type:
Enumeration* = RECORD(Dialog.Enumeration) END;
and a corresponding type-bound method:
PROCEDURE (VAR e: Enumeration) Match* (c: CHAR): LONGINT;
e.Match will be called whenever a key is pressed, and this routine is expected
to return the index of the listbox item that the selection should move to. If
e.Match isnt overridden the default implementation would be the current default
behaviour.
One problem I'm having is accessing the 'link' field of the listbox's control
properties. The link field should contain a string pointing to a record
who'se type is an extension of my Enumeration type.
I need to be able to:
1. get/set the enumeration's 'val' field.
2. call the enumeration's Match method
Using (Meta.) Item.IntVal/PutIntVal I can do (1), but dont see how to properly
do (2). All my attemts to use Item.GetVal fail (the returned 'ok' parameter
is FALSE). I'm guessing this is because my Meta.Val extension contains a field
with a type that is a base-type of the actual variable I'm trying to retrieve,
not the actual type. This is becuase control can't 'know' about the user's
Enumeration extension.
My current kludge is to use Item.Clone, to retrieve a _pointer_ to a clone of
the enumeration, and then call it's Match method. Somehow this works but sure
doesnt seem like the right way to go about things.
Another problem I'm having is: once the Match method returns I need to
update the wrapped listbox. I can set its enumeration's 'val' field but I then
need to cause the screen to be updated. I have two kludges to do this but
neither is good.
The one is to call Views.Update(v.v, FALSE) (v.v is the wrapped listbox) but
this causes an ugly flicker while the entire listbox is re-drawn. The other
kludge is to send the correct number of 'up-arrow' or 'down-arrow' controller
-messages using Views.ForwardCtrlMsg(f, msg), but this too is very slow.
Any suggestions?
This backwards-compatible extension seems to be useful for selection-box and
combo-box controls too. Perhaps it could be considered for inclusion in the
standard control implementation.
Thanks,
Guy.
ps: while I'm making suggestions ;-) it'd be nice if the decoder tool
optionaly logged it's actions to a log file, or even just output to the
log window so I can save manually. I sometimes lose track of which files
originated from which package. As more components become available
this will become more of a problem. I think in general there arent enough
commands to manage encoded files (nor enough details exported from the StdCode
module so one can write one's own). For example a command that takes a filename
and outputs to the log a listing of that file's encoded contents. Or one
that extract a certain file from an archive. etc...