mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-06 06:42:03 +01:00
Author:admin
Date:2008-10-10T16:19:53.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@75 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -103,7 +103,8 @@ initialize_my_preferences is
|
||||
end</code>
|
||||
This will create a new preference, which you can then use in your application to get, set and save the corresponding value when necessary. The issue to be aware of here though involves the value that the preference will contain when it is created. You see in the code above we pass the integer value 480. '''This does not mean, however, the initial value of the preference will be 480'''. This may sound odd, so let me explain...
|
||||
The value of a preference when initialized is determined by a number of factors. The first of these is the underlying data store value. If a preference value was changed in a previous session, by the user or by the application directly, and was saved to the underlying data store, then this value will be given priority. This makes sense, since if a user changes their preferences they don't want to have to do it every time they use your program. So, if they want the default window width to be larger, say 600, then this will be the value of the preference named "window_width" when initialized next time. Following this, if there is no previously saved value then the library will look for a default value to use. If a default file was given when the preferences were created (see above), and this default specifies a default value of 240 for the integer preference called "window_width", then this will be used. Finally, if no preference value was previously stored ''and'' no value is provided as a default value then the supplied value in the code is used - our 480 value from the example above. Although this process may seem confusing it is infact very simple and intuitive way to initialze the preferences. The process chart below illustrates more clearly the various permutations.
|
||||
[[Image:libraries/preferences/content/value_chart.png]]
|
||||
|
||||
[[Image:value-chart]]
|
||||
|
||||
==Using and Manipulating Preferences==
|
||||
Now you have preferences created you may use them from your application. Using the example preference above, window_width_preference, you can query the value of the preferences by simply querying the preference directly:
|
||||
|
||||
Reference in New Issue
Block a user