Friday, December 19, 2014

xBox (a Textbox Control class)

Release 4

  • Made the appearance cleaner by imitating a plain textbox so when you resize on form during design time, you will see the borders cleanly
  • Fixed seeding initial Value via PEM
  • Added seeding via ExtraValue property which displays the correct Value counterpart  
  • Used inherent Picture property for alternate icon.  Removed icon property as that is just a waste of extra unneeded property. Although on form, when a picture for icon is selected, the icon image is shown tiled on the class
  • Added ControlSource, PasswordChar, ReadOnly, FontBold and FontItalic properties

Release 3

Color Toggling on Enabling/Disabling the class - Fixed

Seeding the class via .Value does not perform an AutoComp resulting to .ExtraValue giving a wrong result. Fixed that. However, seeding values to other xBoxes on the form with each having an AutoComp feature enabled short-circuits it; as each tries to perform an AutoComp search during when values are changed.

Solution is to ensure that only the active xBox will perform an AutoComp search. So now, you can do something like this: 

*xBox1's InterActiveChange
*  where search is made and seeding other xBoxes as we type
thisform.xBox2.Value = field2
thisform.xBox3.Value = field3
thisform.xBox4.Value = field6


And only xBox1 will perform the AutoComp search and the others will simply receive the values. Anyway, there is no need for the record pointer to change on those 3 others.

Caveat:

When seeding an xBox where you want it to perform an AutoComp search, then you have to ensure it is the active object in the form. Something like this:

Thisform.xBox1.SetFocus
Thisform.xBox1.Value = 'Whatever'

Say like when you open another form where you want to seed an xBox some value from the calling form and later would also like to reflect the .ExtraValue back, then you have to set focus onto it before the value is seeded.

If you are not after the .ExtraValue though and is only after the .Value, then no need to SetFocus on the class.


Here is the link for the latest class and demo form: https://dl.dropboxusercontent.com/u/15025358/xbox_demo.rar

Enjoy!

Release 2:

What's new:

- Added a protected property named Release just for the sole purpose of differentiating between releases (if any more release will happen in the future)

- Added Caption property.  This is what gets shown inside the box when there is no value



















- Added markers 3 & 4 which are magnifying glasses









- Added Icon property so any of you can customize the marker.  This icon image will be prioritized by the class over the default marker, if any.  If an image to be used as marker is included in the project, then you do not need to include fullpath.  If it is not, you need to include fullpath






- Moved the hover effect from within the textbox object to the class itself.  I was thinking of creating another property to optionally disable this hover effect should the user do not want it.  But then I realized all you need to do to disable this is to ensure that BorderEnter and BorderLeave are of the same RGB().

- Added KeyPress Event


=====

Release 1

What is xBox?  This is a textbox with curvature effect which is a descendant of ssTextBox container class for my ssUltimate library.  Basically, this class is cleaner since I now use a control class type here as against a container class for ssTextBox.

Actually, I decided to create this new control class yesterday because of a post I saw inside Foxite about a textbox with auto-complete.  So I fooled around with codes but before being able to post a way, I found out that our good friend Vilhelm-Ion Praisach has already beaten me in posting there how it can be done.  :)

Another reason why I decided to work on this new class is because I saw that it will be faster for users of my ERP app to have something like that auto-complete instead of using a combobox.  And thus, this new class is born.

Why, you may say, instead of enhancing the old ssTextbox, I created this new one?  Because I am not overly satisfied with that old one being I designed it as a container class before.  Control classes are cleaner in a sense that objects inside won't be shown in the form.  Here are images comparing a container class and a control class when inside a form:

Container Class


 Control Class


However, its strength is also its weakness in the sense that you won't be able to directly reach the objects of the control class from within the instance of the class inside a form as those are somewhat hidden.  For reaching a control class, the developer has to create properties and methods in the class itself; which is what we have here (see new features).

Forwarded Features from ssTextBox:

  • Curvature
  • Marker (check marks)
  • Others (I forgot, just check my blog entry for that)

New features:
  • As mentioned, being a control class type then it is cleaner
  • Added hover effect on border with curvature (although if you have my latest ssClasses as well I shared recently inside Foxite, then this is now also included there).  This is affected by .BorderEnter and .BorderLeave properties of the class, the values you need to put there are RGB() of your taste.
  • AutoComplete Feature (Optional) - If you wanted this class to perform an auto-complete, then you should use these two properties:
    • AutoCompSource - is the record source (cursor or table) subject to seeking
    • AutoCompField - is the fieldname of the recordsource where search would be performed by the class


The class takes advantage of a structural index tag of the same name as the AutoCompField, if there is, and will use SEEK().  If the table does not have that necessary index tag, then it will switch to using LOCATE.

  • Since my goal in creating this new class is to replace some of my comboboxes for faster searching, then I have to have the Combobox' ability to return two possible values at a time.  But it is comparably easier though to return any values from any fields of the AutoCompSource with xBox via the ExtraField and ExtraValue properties. 
Shown below is the comparison between a combobox and xBox:
Combobox xBox
DisplayValue Value
Value ExtraValue
How come I have not swapped the above?  That is because in combobox, no matter where you get the value, what will be shown on the object is always the DisplayValue.  So in the case of xBox, that is the same.  
In combobox, value can come from any column, be it visible or not (see http://sandstorm36.blogspot.com/2012/08/combobox-tricks-part-i.html).  In xBox, ExtraValue then is the same, it can come from any other field aside from the field being displayed (Value).  This ExtraValue is dependent on the  ExtraField property of the class (see demo project).  
  • When AutoComplete feature is used, then when a match is found, it is shown on the current forecolor we set.  When a match is not found, then forecolor turns into red as an added visual indicator









  • Right-click context (just usual stuff like cut, copy, paste, select all, Clear, Undo/Redo last action; maybe I will add more in the future)
  • InteractiveChange Event is added
  • Basic properties like FontSize, FontName, ForeColor, Format, and InputMask are added.  Will add others soon but for now, those are what I basically need

I hope that you will find this useful on your end as well.  I welcome suggestions to improve this further.  Like I said, this is created only yesterday and I have added features based only on what I need right now.  For my subscribers, then this will be part of ssUltimate library.  I will update you all soon.

Cheers!

2 comments: