COMPANY

BLOGS

  • user warning: Unknown column 'u.signature_format' in 'field list' query: SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.thread, c.status FROM comments c INNER JOIN users u ON c.uid = u.uid WHERE c.nid = 19299 AND c.status = 0 ORDER BY c.cid LIMIT 0, 50 in /var/www/www.4d.com/docs/modules/comment/comment.module on line 991.
  • warning: file_get_contents(http://www.telize.com/geoip/54.81.45.122) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/www.4d.com/docs/includes/common.inc(1762) : eval()'d code on line 4.

Objects and Properties

22.07.2010
by Thibaud Arguillère

While a program is running, we often need to access to some types of object properties. For example, we can dynamically move and resize an object, change it to bold or italic, or modify the title of a button...

 

The “Object properties” language theme has been reworked a lot in 4D v12: Commands have been renamed, and new commands and functionalities have been added.


Every major version of 4D usually includes some changed command names – It’s kind of a tradition. It can be surprising, though, to discover that a command we used often doesn't work anymore. But at the end, we learn to adjust quickly. (Well, I must admit that I had hard time when INSERT ELEMENT became INSERT IN ARRAY in 4D v11 SQL). 4D v12 maintains this tradition and pushes it as far as possible regarding the “Object properties” theme: All commands have been renamed! They now all start with the “OBJECT” prefix, which is a good idea, especially when you use type-ahead often. Now, all commands are grouped so it’s easier to find the right one:

Typeahead

Beyond this renaming, 4D v12 brings more consistency in the way object properties can be dynamically handled. Now, every GET has its SET counterpart:
 

OBJECT SET ENABLED

OBJECT Get enabled

OBJECT SET ALIGNMENT

OBJECT Get alignment

OBJECT SET STYLED TEXT ATTRIBUTES

OBJECT GET STYLED TEXT ATTRIBUTES

OBJECT SET SCROLLBAR

OBJECT GET SCROLLBAR

OBJECT SET RGB COLORS

OBJECT GET RGB COLORS

OBJECT SET SCROLL POSITION

OBJECT GET SCROLL POSITION

OBJECT MOVE

OBJECT GET COORDINATES

OBJECT SET FILTER

OBJECT Get filter

OBJECT SET FORMAT

OBJECT Get format

OBJECT SET CHOICE LIST NAME

OBJECT Get choice list name

OBJECT SET FONT

OBJECT Get font

OBJECT SET ENTERABLE

OBJECT Get enterable

OBJECT SET FONT STYLE

OBJECT Get font style

OBJECT SET FONT SIZE

OBJECT Get font size

OBJECT SET STYLED TEXT

OBJECT Get styled text

OBJECT SET TITLE

OBJECT Get title

OBJECT SET VISIBLE

OBJECT Get visible

 

If a GET command does not have its SET counterpart (or vice-versa), it is likely because it doesn't need one. Typically, OBJECT GET BEST SIZE can’t have an OBJECT SET BEST SIZE twin, because it returns values dependent the content of the object. It is a bit different for OBJECT SET COLOR which uses the good old 4D color palette: To get the color of an object, only the red/green/blue values accessor, OBJECT GET RGB COLORS, can be used.

 

The new OBJECT Get enabled/SET ENABLED commands replace DISABLE BUTTON/ENABLE BUTTON, which are now officially deprecated. We, as 4D developers, are encouraged to replace the old commands with the new ones, as they are much more efficient. Not only is their scope limited to the current form, but the name is clearer. I always found it strange to call DISABLE BUTTON on a combo-box, which is obviously not a button!

 

Finally, longtime developers will find OBJECT Get title very interesting, as it can also return the title of a button (who just said “At last!”?)… Furthermore, it can also return the contents of static text (typically a field label or a prompt sentence). And going even further, the OBJECT SET TITLE command also works on static text! This made us say  – during various 4D v12 Devcons around the world – that we invented the concept of “Dynamic Static” text!  Here's how it works:

 

 

 

RSS 0 comment(s) to this post