Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who is Online
61 user(s) are online (43 user(s) are browsing Forum)

Members: 0
Guests: 61

more...


Browsing this Thread:   1 Anonymous Users






Re: Shadow button problem
#4
Home away from home
Home away from home


See User information
@mrdarek
By the way, you can replaces all of this code:
<pre> IF testvalue>50
guiShadow.setGhosted(TRUE)
ELSE
guiShadow.setGhosted(FALSE)
ENDIF</pre>

With just this code:
<pre> guiShadow.setGhosted(testvalue>50)</pre>

That is probably less understandable for beginners though! The reason you can do this is that you can imagine your original code does something (not exactly!) like this:
<pre> IF (testvalue>50) = TRUE
guiShadow.setGhosted(TRUE)
ELSE
guiShadow.setGhosted(FALSE)
ENDIF</pre>

Posted on: 2011/5/10 8:09
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Shadow button problem
#3
Just can't stay away
Just can't stay away


See User information
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
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Re: Shadow button problem
#2
Home away from home
Home away from home


See User information
@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
ChrisH
--
Author of the PortablE programming language.
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 


Shadow button problem
#1
Just can't stay away
Just can't stay away


See User information
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
 Top  Twitter  Facebook  Google Plus  Linkedin  Del.icio.us  Digg  Reddit  Mr. Wong 







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.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4462
2 nikolaos
nikolaos
4206
3 magorium
magorium
4095
4 phoenixkonsole
phoenixkonsole
3942
5 deadwood
deadwood
2917
6 ncafferkey
ncafferkey
2810
7 mazze
mazze
2222
8 Kalamatee
Kalamatee
2212
9 clusteruk
clusteruk
2114
Powered by XOOPS © 2001-2025 The XOOPS Project