Browsing this Thread:
1 Anonymous Users
|
Re: Shadow button problem
|
||||
|---|---|---|---|---|
|
Just can't stay away
![]() |
OK, I don't put button in shadow state like you because I think that this button will be in shadow forever. After execute gui.Pages.setState(0) I suppose that program start read definitions for first page and always set button in shade state. Now I see that program only one time read this code and after recalling State0 program create it from memory - not from startup definitions...
Posted on: 2011/5/10 7:27
|
|||
|
||||
|
Re: Shadow button problem
|
||||
|---|---|---|---|---|
|
Home away from home
![]()
|
@mrdarek
<pre>guiShadow.setGhosted(TRUE) ->this line give error</pre> I am not surprised that this line causes a crash, because you are trying to use a method on the "guiShadow" object... before the object has been created! In fact, you are also doing it before the CreateApp() line, and that is ALSO a very bad idea! The guiShadow object is not created until the following line: <pre>guiShadow := win.addButton('shade or not')</pre> So you can EITHER add the following line after this point: <pre>guiShadow.setGhosted(TRUE)</pre> OR you can make the addButton line more complicated: <pre>guiShadow := win.addButton('shade or not').setGhosted(TRUE)</pre> So the fixed program looks like this: <pre>MODULE 'std/cGui' PROC main() DEF quit:BOOL DEF win:PTR TO cGuiWindow, item:PTR TO cGuiItem DEF guiPages:PTR TO cGuiGroupPage DEF guiPage0:PTR TO cGuiItem, guiButtonGo:PTR TO cGuiButton, guiTextBox:PTR TO cGuiTextBox DEF guiPage1:PTR TO cGuiItem, guiButtonReturn:PTR TO cGuiButton DEF guiShadow:PTR TO cGuiButton DEF testvalue:INT DEF testvaluetxt[5]:STRING DEF guiSetmeplease:PTR TO cGuiSlider ->this should be done before you do ANYTHING else: CreateApp().build() ->equivalent to IsDesktopApp() testvalue := 2 StringF(testvaluetxt,'\d',testvalue) ->create the GUI win := CreateGuiWindow('example') guiPages := win.beginGroupPage() guiPage0 := win.beginGroupVertical() guiShadow := win.addButton('shade or not').setGhosted(TRUE) ->if testvalue>50 button is in shadow state guiTextBox := win.addTextBox('').setState(testvaluetxt) guiButtonGo := win.addButton('Go') win.endGroup() guiPage1 := win.beginGroupVertical() guiSetmeplease := win.addSlider('testvalue', 0, 100).setState(50) guiButtonReturn := win.addButton('Return') win.endGroup() win.endGroup() win.build() ->OR you can do this instead: ->guiShadow.setGhosted(TRUE) ->handle GUI events quit := FALSE REPEAT item := WaitForChangedGuiItem() SELECT item CASE NIL ->(a non-item event occured) so check if user tried to close the window IF win.getCloseRequest() THEN quit := TRUE CASE guiSetmeplease testvalue := guiSetmeplease.getState()!!INT StringF(testvaluetxt,'\d',testvalue) guiTextBox.setState(testvaluetxt) IF testvalue>50 guiShadow.setGhosted(TRUE) ELSE guiShadow.setGhosted(FALSE) ENDIF CASE guiButtonGo ->Print('Go button was pressed\n') ->this is one way of changing the visible page guiPages.setState(1) ->but we could have used: ->guiPages.setStateItem(guiPage1) CASE guiButtonReturn testvalue := guiSetmeplease.getState()!!INT StringF(testvaluetxt,'\d',testvalue) guiTextBox.setState(testvaluetxt) IF testvalue>50 guiShadow.setGhosted(TRUE) ELSE guiShadow.setGhosted(FALSE) ENDIF ->Print('Return button was pressed\n') ->this is another way of changing the visible page guiPages.setStateItem(guiPage0) ->but we could have used: ->guiPages.setState(0) ENDSELECT UNTIL quit win.close() FINALLY PrintException() ENDPROC</pre>
Posted on: 2011/5/9 19:49
Edited by PortablE on 2011/5/10 8:06:02
|
|||
|
||||
|
Shadow button problem
|
||||
|---|---|---|---|---|
|
Just can't stay away
![]() |
I modify little code from slider example and add button that can be shadow if testvalue>50. Action for this button is not important here-not implemented. Here is working code:
<pre> MODULE 'std/cGui' PROC main() DEF quit:BOOL DEF win:PTR TO cGuiWindow, item:PTR TO cGuiItem DEF guiPages:PTR TO cGuiGroupPage DEF guiPage0:PTR TO cGuiItem, guiButtonGo:PTR TO cGuiButton, guiTextBox:PTR TO cGuiTextBox DEF guiPage1:PTR TO cGuiItem, guiButtonReturn:PTR TO cGuiButton DEF guiShadow:PTR TO cGuiButton DEF testvalue:INT DEF testvaluetxt[5]:STRING DEF guiSetmeplease:PTR TO cGuiSlider testvalue := 2 StringF(testvaluetxt,'\d',testvalue) -> guiShadow.setGhosted(TRUE) ->this line give error CreateApp().build() ->equivalent to IsDesktopApp() ->create the GUI win := CreateGuiWindow('example') guiPages := win.beginGroupPage() guiPage0 := win.beginGroupVertical() guiShadow := win.addButton('shade or not') ->if testvalue>50 button is in shadow state guiTextBox := win.addTextBox('').setState(testvaluetxt) guiButtonGo := win.addButton('Go') win.endGroup() guiPage1 := win.beginGroupVertical() guiSetmeplease := win.addSlider('testvalue', 0, 100).setState(50) guiButtonReturn := win.addButton('Return') win.endGroup() win.endGroup() win.build() ->handle GUI events quit := FALSE REPEAT item := WaitForChangedGuiItem() SELECT item CASE NIL ->(a non-item event occured) so check if user tried to close the window IF win.getCloseRequest() THEN quit := TRUE CASE guiSetmeplease testvalue := guiSetmeplease.getState()!!INT StringF(testvaluetxt,'\d',testvalue) guiTextBox.setState(testvaluetxt) IF testvalue>50 guiShadow.setGhosted(TRUE) ELSE guiShadow.setGhosted(FALSE) ENDIF CASE guiButtonGo ->Print('Go button was pressed\n') ->this is one way of changing the visible page guiPages.setState(1) ->but we could have used: ->guiPages.setStateItem(guiPage1) CASE guiButtonReturn testvalue := guiSetmeplease.getState()!!INT StringF(testvaluetxt,'\d',testvalue) guiTextBox.setState(testvaluetxt) IF testvalue>50 guiShadow.setGhosted(TRUE) ELSE guiShadow.setGhosted(FALSE) ENDIF ->Print('Return button was pressed\n') ->this is another way of changing the visible page guiPages.setStateItem(guiPage0) ->but we could have used: ->guiPages.setState(0) ENDSELECT UNTIL quit win.close() FINALLY PrintException() ENDPROC </pre> But I need ghosted button on start!!! So I add (please remove comment in code.... for fast edit, and better change testvalue to 52....): <pre> guiShadow.setGhosted(TRUE) ->this line give error </pre> Program is compiling and after run crash In my game I have button "continue" - it must be in shadow state on start.... Anyone can repair this code?
Posted on: 2011/5/9 19:11
|
|||
|
||||
You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.






