-
button disable?
From
john c@21:1/5 to
All on Tue Sep 14 11:58:00 2021
hi all,
i've had a problem for quite a while. i have a dialog where one button should be enabled/disabled based the values of some instance variables. i have included what i think are the relevant methods. the enable/disable is not working.
i'm running on v7.1.20 but have had the same problem with 7.0.57.
any thoughts will be appreciated.
john
queryCommand: aCommandQuery
super queryCommand: aCommandQuery.
(self canEnableLoad)
ifTrue:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ aCommandQuery beEnabled ]]
ifFalse:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ aCommandQuery beDisabled ]].
canEnableLoad
(hasRegion)
ifFalse:[^false].
(hasFilePath )
ifFalse:[^false].
(hasFileType )
ifFalse:[^false].
canEnablePresenter value: true.
^true
openOn: aJCModel
(aJCModel isNil)
ifTrue:[self model: self class defaultModel]
ifFalse:[self model: aJCModel ].
self preOpenProcess.
self halt. <== hasRegion, hasFilePath, hasFileType are all false here
^self showModal. <== load button enabled (it is assoc with method onLoadEnabled)
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
vinref@gmail.com@21:1/5 to
All on Tue Sep 14 21:03:12 2021
Hi John
Does the button have a command connected to it? If it does it should be enabled by default.
It is difficult to tell from you snippet the exact problem, but can you mock the call to the code in the body of the #queryCommand: method? I.e., if you call
(self canEnableLoad)
ifTrue:[(true) ifTrue: [ aCommandQuery beEnabled ]]
ifFalse:[(true) ifTrue: [ aCommandQuery beDisabled ]].
does anything different happen?
Vince
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john c@21:1/5 to
All on Wed Sep 15 11:07:13 2021
hi vince,
i took your suggestions (code below). bottom line is that method which sets variables and the boolean method which queryCommand reference, are working correctly. beyond that i setup queryCommand to "false" and button is still enabled.
john
queryCommand: aCommandQuery
super queryCommand: aCommandQuery.
(false "self canEnableLoad") <== should disable the button assoc with (#onLoadEnabled) ... doesn't
ifTrue:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ aCommandQuery beEnabled ]]
ifFalse:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ aCommandQuery beDisabled ]].
updateUI: aParser <== method which sets instance vars which queryCommand cares about
| bool |
bool := self canEnableLoad. <== method in #queryCommand: first time in false here
self halt.
wpRegionPresenter model: (aParser fileRegion).
hasRegion := true.
wpFileTypePresenter model: (aParser fileType).
hasFileType := true.
wpFullPathPresenter model: (aParser filePath).
hasFilePath := true.
bool := self canEnableLoad. <== bool is true, so #canEnableLoad is working
self halt.
fileType := (aParser fileType).
fileName := (aParser filePath).
regionName := (aParser fileRegion).
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john.aspinall@gmail.com@21:1/5 to
john c on Thu Sep 16 00:41:19 2021
Hi John - I haven't looked in detail at this but I think you should be checking the commandSymbol of aCommandQuery, i.e.
(#(#onLoadEnabled) includes: aCommandQuery commandSymbol) ifTrue: [ aCommandQuery beDisabled ]
Hope this helps.
John Aspinall
On Wednesday, September 15, 2021 at 7:07:14 PM UTC+1, john c wrote:
hi vince,
i took your suggestions (code below). bottom line is that method which sets variables and the boolean method which queryCommand reference, are working correctly. beyond that i setup queryCommand to "false" and button is still enabled.
john
queryCommand: aCommandQuery
super queryCommand: aCommandQuery.
(false "self canEnableLoad") <== should disable the button assoc with (#onLoadEnabled) ... doesn't
ifTrue:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ aCommandQuery beEnabled ]]
ifFalse:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ aCommandQuery beDisabled ]].
updateUI: aParser <== method which sets instance vars which queryCommand cares about
| bool |
bool := self canEnableLoad. <== method in #queryCommand: first time in false here
self halt.
wpRegionPresenter model: (aParser fileRegion).
hasRegion := true.
wpFileTypePresenter model: (aParser fileType).
hasFileType := true.
wpFullPathPresenter model: (aParser filePath).
hasFilePath := true.
bool := self canEnableLoad. <== bool is true, so #canEnableLoad is working self halt.
fileType := (aParser fileType).
fileName := (aParser filePath).
regionName := (aParser fileRegion).
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john c@21:1/5 to
All on Thu Sep 16 06:05:03 2021
hi john,
unfortunately this didn't fix it.
john
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
vinref@gmail.com@21:1/5 to
All on Thu Sep 16 17:00:50 2021
Hi John
Are you able to test this and tell us what you get in the Transcript?
queryCommand: aCommandQuery
| comm |
comm := aCommandQuery command.
Transcript nextPutAll: comm printString; cr
Vince
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
vinref@gmail.com@21:1/5 to
john c on Thu Sep 16 18:02:42 2021
On Friday, 17 September 2021 at 10:42:01 UTC+10, john c wrote:
hi vince,
i've attached queryCommand from my problem dialog, but it doesn't produce any output.
...
queryCommand: aCommandQuery <== queryCommand from problem dialog
| comm |
super queryCommand: aCommandQuery.
comm := aCommandQuery command.
Transcript nextPutAll: 'Cmd ', comm printString, Character cr.
This won't print anything out as you need to send the message #cr to the Transcript to flush the line. You will need to do this:
Transcript nextPutAll: 'Cmd ', comm printString; cr.
Vince
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john c@21:1/5 to
All on Thu Sep 16 17:42:00 2021
hi vince,
i've attached queryCommand from my problem dialog, but it doesn't produce any output.
as a side note i created a new test dialog outside of the hierarchy of my base dialog and it worked fine. so i created a completely new dialog as a sub class of my base dialog and it doesn't work. so i have to assume there is something funky in my dialog
hierarchy but i have no clue where to start. i attached the queryCommand from my base dialog.
queryCommand: aCommandQuery <== queryCommand from problem dialog
| comm |
super queryCommand: aCommandQuery.
comm := aCommandQuery command.
Transcript nextPutAll: 'Cmd ', comm printString, Character cr.
(false "self canEnableLoad")
ifTrue:[(#(#onLoadEnabled) includes: aCommandQuery commandSymbol) ifTrue: [ aCommandQuery beEnabled ]]
ifFalse:[(#(#onLoadEnabled) includes: aCommandQuery commandSymbol) ifTrue: [ aCommandQuery beDisabled ]].
queryCommand: aCommandQuery <== from my base dialog class
super queryCommand: aCommandQuery.
(#(#cancel) includes: aCommandQuery command) ifTrue: [ aCommandQuery beEnabled ].
(self isDirty)
ifTrue:[(#(#ok) includes: aCommandQuery command) ifTrue: [ aCommandQuery beEnabled ]]
ifFalse:[(#(#ok) includes: aCommandQuery command) ifTrue: [ aCommandQuery beDisabled ]].
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john c@21:1/5 to
All on Fri Sep 17 05:26:32 2021
hi vince,
sorry, missed the semi-colon.
here is transcript
Cmd #ok
Cmd #cancel
Cmd #openFindFile
Cmd #onLoadEnabled
Cmd #ok
Cmd #cancel
Cmd #openFindFile
Cmd #onLoadEnabled
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john c@21:1/5 to
All on Fri Sep 17 06:20:15 2021
it strikes me that the problem must be the includes: is failing.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
vinref@gmail.com@21:1/5 to
john c on Fri Sep 17 18:23:24 2021
On Friday, 17 September 2021 at 23:20:16 UTC+10, john c wrote:
it strikes me that the problem must be the includes: is failing.
You should now try substituting the #beEnabled: message send with a Transcript output:
(self canEnableLoad)
ifTrue:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ Transcript nextPutAll: 'Enabled'; cr ]]
ifFalse:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ Transcript nextPutAll: 'Disabled'; cr ]].
By the way is the button in a Presenter or in a Shell?
Vince
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
vinref@gmail.com@21:1/5 to
john c on Fri Sep 17 18:22:34 2021
On Friday, 17 September 2021 at 23:20:16 UTC+10, john c wrote:
it strikes me that the problem must be the includes: is failing.
You should now try substituting the #beEnabled: message send with a Transcript output:
(self canEnableLoad)
ifTrue:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ Transcript nextPutAll: 'Enabled'; cr ]]
ifFalse:[(#(#onLoadEnabled) includes: aCommandQuery command) ifTrue: [ Transcript nextPutAll: 'Enabled'; cr ]].
By the way is the button in a Presenter or in a Shell?
Vince
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john c@21:1/5 to
All on Sat Sep 18 06:37:27 2021
hi vince,
transcript shows Disabled
button is still enabled
button is in a shell(dialog) at the same level as the cancel/ok
john
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john c@21:1/5 to
All on Sat Sep 18 09:13:10 2021
did some experimenting.
created a new shell with only menu option to open the problem dialog. it worked!
i went to the "real" shell and just selected the menu to open the problem dialog. it worked!
i then went back and went thru the same sequence except for opening the db before opening the dialog. it failed.
i went and opened the dialog (good result), then open the db, and then opened the dialog again. it failed.
so it has something to do with what is going on in my shell/openDb. any suggestions on what i should be looking for in my main shell which would cause queryCommand to not work in a dialog?
btw, thanks for all your help.
john
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
-
From
john c@21:1/5 to
All on Sat Sep 18 11:55:37 2021
On Saturday, September 18, 2021 at 12:13:11 PM UTC-4, john c wrote:
i think i figured it out.
in my main shell i had the method name the same as the method name in the dialog. i enabled/disabled the method in the main shell queryCommand based on whether the db was open or not. subsequently i changed the name of the main shell message but forgot
to change the name in the main shell queryCommand. so it appears the queryCommand of the main shell overrides the queryCommand in the dialog if there is a method name clash. i assume this is the result of symbols being globally unique.
thanks for all your help.
john
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)