Experiments with the placing of addModifiedListener calls

Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 343
Joined: 24 Apr 2007 12:26

Experiments with the placing of addModifiedListener calls

Unread post by Ferenc Nagy » 11 Nov 2013 10:28

Hi,

I intended to enlist the modified fields in the status line.

Code: Select all

% 2013.10.29. Add an element to the list of unconfirmed modifications.     addUnconfirmed(Handle,Tag) :-         unconfirmed_modifications:=list::removeDuplicates([Tag|unconfirmed_modifications]),         C=string::concatWithDelimiter(unconfirmed_modifications,", "),         winsetText(Handle,formatTitle()),         M=string::format("% %.","Press [OK] to confirm modified",string::toLowerCase(C)),         Task=vpi::getTaskWindow(),         vpiToolbar::setValue(Task, resourceIdentifiers::idt_help_line, vpitoolbar::text_value(M)).
I placed the calls of the above predicate in the modifiedListeners so.

Code: Select all

predicates     onNumberIntModified : editControl::modifiedListener.     onAIntModified : editControl::modifiedListener.     onBIntModified : editControl::modifiedListener.     onCIntModified : editControl::modifiedListener.     onDIntModified : editControl::modifiedListener.     onAlphaRealModified : editControl::modifiedListener.     onBetaRealModified : editControl::modifiedListener.     onGammaRealModified : editControl::modifiedListener.     onDeltaRealModified : editControl::modifiedListener.   clauses     onNumberIntModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"lines").     onAIntModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"a").     onBIntModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"b").     onCIntModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"c").     onDIntModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"d").     onAlphaRealModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"alpha").     onBetaRealModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"beta").     onGammaRealModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"gamma").     onDeltaRealModified(_Source)  :-         addUnconfirmed(getVPIWindow(),"delta").
When I defined the listeners in the property sheet and the program generated their definition automatically in the procedure generatedInitialize

Code: Select all

num_lines_int:addModifiedListener(onNumberIntModified),         a_int:addModifiedListener(onAIntModified),         b_int:addModifiedListener(onBIntModified),         c_int:addModifiedListener(onCIntModified),         d_int:addModifiedListener(onDIntModified),         alpha_real:addModifiedListener(onAlphaRealModified),         beta_real:addModifiedListener(onBetaRealModified),         gamma_real:addModifiedListener(onGammaRealModified),         delta_real:addModifiedListener(onDeltaRealModified),        
they were automatically called from the onShow event handler when it filled up the editable fields.
That is, the unchanged fields were reported as unconfirmed modifications.

I moved the above definition lines after the setting of editable fields in the onShow event handler.

Code: Select all

onShow(Window, _Data) :-         setEditFields(IniSetting),         num_lines_int:addModifiedListener(onNumberIntModified),


Of course I had to remove their settings from the property sheet of the form to avoid duplicate definitions.

I have to use very short field tags in the status line toolbar:

Code: Select all

addUnconfirmed(getVPIWindow(),"lines")
unlike in the validation messages where I have to use longer ones:

Code: Select all

num_lines_int:setLabel("The maximal number of the lines of the message window")
therefore I could not use the labels of integer and real fields and single common modified listener for each integer and real controls.
TIA, Regards,
Frank Nagy

Post Reply