Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Update editField in a paint event (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: Windows thinks I have a demo version of RealBasic
Next thread: Return value Red if negative


RB Database   -   tom.russell transport.alstom.com
  Update editField in a paint event   -   Barrie Jones
   Re: Update editField in a paint event   -   Paul Young
   Re: Update editField in a paint event   -   Barrie Jones
   Re: Update editField in a paint event   -   Joseph J. Strout
   Re: Update editField in a paint event   -   Phil M
   Re: Update editField in a paint event   -   CV
   Re: Update editField in a paint event   -   Barrie Jones
    RE: Update editField in a paint event   -   RBNUBE
     Re: Update editField in a paint event   -   Barrie Jones

Update editField in a paint event
Date: 01.02.05 00:27 (Mon, 31 Jan 2005 18:27:08 -0500)
From: Barrie Jones
Can someone please let me know if the following editField behavior is
normal or possibly caused by my program.
The setup:
I have an EditField that should be updated each time a graphics
operation is performed.
The update code, myField.text = str(number) is in a graphics method
called by the canvas paint event.
"number" is incremented every time the paint event is fired.
The problem:
myField.text appears to update with the first pass, but remains the
same after each subsequent pass through the paint event.

The problem is fixed by placing myField.text = str(number) outside the
paint event.

Another problem that may or may not be related is that MsgBox text does
not show up in methods called by a canvas paint event. A msgBox window
appears on cue, but the window is blank. (No text and No button). The
invisible button can be activated with return or a well placed mouse
click.

If the above is not normal behavior, I will dig deeper into my code.

iBook G4, OSX, RB 5.5.3

Thanks
Barrie

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: Update editField in a paint event
Date: 01.02.05 01:08 (Mon, 31 Jan 2005 19:08:00 -0500)
From: Paul Young
Barry,

Add:

editField.Refresh

Paul

On Jan 31, 2005, at 6:27 PM, Barrie Jones wrote:

> Can someone please let me know if the following editField behavior is
> normal or possibly caused by my program.
> The setup:
> I have an EditField that should be updated each time a graphics
> operation is performed.
> The update code, myField.text = str(number) is in a graphics method
> called by the canvas paint event.
> "number" is incremented every time the paint event is fired.
> The problem:
> myField.text appears to update with the first pass, but remains the
> same after each subsequent pass through the paint event.
>
> The problem is fixed by placing myField.text = str(number) outside the
> paint event.
>
> Another problem that may or may not be related is that MsgBox text
> does not show up in methods called by a canvas paint event. A msgBox
> window appears on cue, but the window is blank. (No text and No
> button). The invisible button can be activated with return or a well
> placed mouse click.
>
> If the above is not normal behavior, I will dig deeper into my code.
>
> iBook G4, OSX, RB 5.5.3
>
> Thanks
> Barrie
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://www.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: Update editField in a paint event
Date: 01.02.05 01:25 (Mon, 31 Jan 2005 19:25:20 -0500)
From: Barrie Jones
Paul, thanks for the suggestion.
Unfortunately, it did not fix the problem.
Barrie
On Jan 31, 2005, at 7:08 PM, Paul Young wrote:

> Barry,
>
> Add:
>
> editField.Refresh
>
> Paul
>
> On Jan 31, 2005, at 6:27 PM, Barrie Jones wrote:
>
>> Can someone please let me know if the following editField behavior is
>> normal or possibly caused by my program.
>> The setup:
>> I have an EditField that should be updated each time a graphics
>> operation is performed.
>> The update code, myField.text = str(number) is in a graphics method
>> called by the canvas paint event.
>> "number" is incremented every time the paint event is fired.
>> The problem:
>> myField.text appears to update with the first pass, but remains the
>> same after each subsequent pass through the paint event.
>>
>> The problem is fixed by placing myField.text = str(number) outside
>> the paint event.
>>
>> Another problem that may or may not be related is that MsgBox text
>> does not show up in methods called by a canvas paint event. A msgBox
>> window appears on cue, but the window is blank. (No text and No
>> button). The invisible button can be activated with return or a well
>> placed mouse click.
>>
>> If the above is not normal behavior, I will dig deeper into my code.
>>
>> iBook G4, OSX, RB 5.5.3
>>
>> Thanks
>> Barrie
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives of this list here:
>> <http://www.realsoftware.com/listarchives/lists.html>
>>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://www.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: Update editField in a paint event
Date: 01.02.05 03:51 (Mon, 31 Jan 2005 20:51:34 -0600)
From: Joseph J. Strout
At 6:27 PM -0500 1/31/05, Barrie Jones wrote:

> "number" is incremented every time the paint event is fired.
>The problem:
>myField.text appears to update with the first pass, but remains the
>same after each subsequent pass through the paint event.

I suspect some simple problem -- try to reproduce it in a simple
project, and if you can, post the relevant code.

Best,
- Joe

Re: Update editField in a paint event
Date: 01.02.05 04:16 (Mon, 31 Jan 2005 19:16:50 -0800)
From: Phil M
On Jan 31, 2005, at 3:27 PM, Barrie Jones wrote:

> Can someone please let me know if the following editField behavior is
> normal or possibly caused by my program.
>
> The setup:
> I have an EditField that should be updated each time a graphics
> operation is performed.
> The update code, myField.text = str(number) is in a graphics method
> called by the canvas paint event.
> "number" is incremented every time the paint event is fired.
>
> The problem:
> myField.text appears to update with the first pass, but remains the
> same after each subsequent pass through the paint event.

If you are running OS X, then it is possible that the Paint event only
gets called once, and therefore your Editfield only gets updated once.
OS X uses what is called double buffering and will display the last
picture unless you tell it to redraw.

Try something else -- in addition to drawing your picture also draw the
number that you want incremented in the canvas as well. Do something
like this:

g.TextSize = 48
g.ForeColor = &cFF00FF // a nice visible color (pink)
myNumber = myNumber + 1
g.DrawString(Str(myNumber), 0, 48)

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: Update editField in a paint event
Date: 01.02.05 07:40 (Tue, 1 Feb 2005 00:40:19 -0600)
From: CV
Hopefully, Number is not a local variable.

In a simple project, with Number as Integer added as a window property,
it works fine for me:

In Paint event:
self.Number = self.Number + 1
EditField1.text = str(self.Number)

When I resize the window, the editfield displays the correct count.

HTH,

Jack

On Jan 31, 2005, at 5:27 PM, Barrie Jones wrote:

> Can someone please let me know if the following editField behavior is
> normal or possibly caused by my program.
> The setup:
> I have an EditField that should be updated each time a graphics
> operation is performed.
> The update code, myField.text = str(number) is in a graphics method
> called by the canvas paint event.
> "number" is incremented every time the paint event is fired.
> The problem:
> myField.text appears to update with the first pass, but remains the
> same after each subsequent pass through the paint event.
>
> The problem is fixed by placing myField.text = str(number) outside the
> paint event.
>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: Update editField in a paint event
Date: 01.02.05 23:59 (Tue, 1 Feb 2005 17:59:31 -0500)
From: Barrie Jones
Thank you Jack. "Number" is a parameter variable. I also tried it as a
global variable and as a window property without success. "Number" is
incrementing OK because it affects the graphics. It seems that the
editfield is dead when it is in the graphics method. It is not a show
stopper since it works OK outside the graphics method but this requires
the code to be placed in four places.
By the way, "number" increments each time other editfields get a
keyDown event (four of them). The KeyDown event activates a canvas
paint event with canvas1.refresh. A fifth editField displays "number"
----> myField.text = str(number) which works OK when myField.text =
str(number) is placed in each of the four keyDown events but not when
it is only placed in the paint event. It displays correctly on the
first pass only but not on subsequent passes. myField.refresh does not
help.
I will try to replicate the problem with a simplified example as
suggested by Joe. In the meantime, if anyone spots a clue in the above
description, please let me know.
Thanks
Barrie

On Feb 1, 2005, at 1:40 AM, CV wrote:

> Hopefully, Number is not a local variable.
>
> In a simple project, with Number as Integer added as a window
> property, it works fine for me:
>
> In Paint event:
> self.Number = self.Number + 1
> EditField1.text = str(self.Number)
>
> When I resize the window, the editfield displays the correct count.
>
> HTH,
>
> Jack
>
> On Jan 31, 2005, at 5:27 PM, Barrie Jones wrote:
>
>> Can someone please let me know if the following editField behavior is
>> normal or possibly caused by my program.
>> The setup:
>> I have an EditField that should be updated each time a graphics
>> operation is performed.
>> The update code, myField.text = str(number) is in a graphics method
>> called by the canvas paint event.
>> "number" is incremented every time the paint event is fired.
>> The problem:
>> myField.text appears to update with the first pass, but remains the
>> same after each subsequent pass through the paint event.
>>
>> The problem is fixed by placing myField.text = str(number) outside
>> the paint event.
>>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://www.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

RE: Update editField in a paint event
Date: 02.02.05 05:00 (Tue, 1 Feb 2005 23:00:57 -0500)
From: RBNUBE
You should be able to use RefreshRect (not simply EditField1.Refresh).

RefreshRect(Left, Top, Width, Height)

This worked when placed in the Paint event of the Canvas in a window
with a Canvas, an EditField and a PushButton and a property I named
theNumber as Integer. theNumber increments each time the button is
pressed.

Canvas Paint:
EditField1.Text = str(theNumber)

EditField1.RefreshRect(EditField1.left,EditField1.top,EditField1.Width,E
ditField1.Height)

RefreshRect doesn't work as I would expect. I would assume that you
would use the control's left, top, width and height settings, but for
some reason, it doesn't work that way. I had to move the EditField into
a position where the refresh was occurring. You might have to play
around with the numbers. If the settings are not correct, the whole
window will jitter with each refresh. Very annoying, but will probably
only be noticeable on Windows. Also, if the EditField has the focus,
the cursor will jitter apparently even if the RefreshRect settings are
correct, on Windows, and probably Mac. You might get by with removing
the focus from the EditField if it ever gets focus.

Another side effect is that the user will not be able to type or copy
the text in the EditField. If this isn't important, use a StaticText
box instead of an EditField.

I don't think Paint events are really intended for this sort of thing.
Is using 4 lines of extra code in four different places, when you
technically don't have to, that big of a deal? :)

HTH and I hope I didn't misunderstand the situation.


-----Original Message-----
From: <email address removed>
[mailto:<email address removed>] On Behalf Of
Barrie Jones
Sent: Tuesday, February 01, 2005 6:00 PM
To: Getting Started
Subject: Re: Update editField in a paint event

Thank you Jack. "Number" is a parameter variable. I also tried it as a
global variable and as a window property without success. "Number" is
incrementing OK because it affects the graphics. It seems that the
editfield is dead when it is in the graphics method. It is not a show
stopper since it works OK outside the graphics method but this requires
the code to be placed in four places.
By the way, "number" increments each time other editfields get a
keyDown event (four of them). The KeyDown event activates a canvas
paint event with canvas1.refresh. A fifth editField displays "number"
----> myField.text = str(number) which works OK when myField.text str(number) is placed in each of the four keyDown events but not when
it is only placed in the paint event. It displays correctly on the
first pass only but not on subsequent passes. myField.refresh does not
help.
I will try to replicate the problem with a simplified example as
suggested by Joe. In the meantime, if anyone spots a clue in the above
description, please let me know.
Thanks
Barrie

On Feb 1, 2005, at 1:40 AM, CV wrote:

> Hopefully, Number is not a local variable.
>
> In a simple project, with Number as Integer added as a window
> property, it works fine for me:
>
> In Paint event:
> self.Number = self.Number + 1
> EditField1.text = str(self.Number)
>
> When I resize the window, the editfield displays the correct count.
>
> HTH,
>
> Jack
>
> On Jan 31, 2005, at 5:27 PM, Barrie Jones wrote:
>
>> Can someone please let me know if the following editField behavior is
>> normal or possibly caused by my program.
>> The setup:
>> I have an EditField that should be updated each time a graphics
>> operation is performed.
>> The update code, myField.text = str(number) is in a graphics method
>> called by the canvas paint event.
>> "number" is incremented every time the paint event is fired.
>> The problem:
>> myField.text appears to update with the first pass, but remains the
>> same after each subsequent pass through the paint event.
>>
>> The problem is fixed by placing myField.text = str(number) outside
>> the paint event.
>>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://www.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

Re: Update editField in a paint event
Date: 02.02.05 21:08 (Wed, 2 Feb 2005 15:08:02 -0500)
From: Barrie Jones
Thanks to all that have tried to help. As Joe suggested, I finally made
a small application that demonstrates the problem.
I don't think I am allowed to send it to the list. Are you there Joe?
If not, who shall I send it to?
Barrie

On Feb 1, 2005, at 11:00 PM, RBNUBE wrote:

> You should be able to use RefreshRect (not simply EditField1.Refresh).
>
> RefreshRect(Left, Top, Width, Height)
>
> This worked when placed in the Paint event of the Canvas in a window
> with a Canvas, an EditField and a PushButton and a property I named
> theNumber as Integer. theNumber increments each time the button is
> pressed.
>
> Canvas Paint:
> EditField1.Text = str(theNumber)
>
> EditField1.RefreshRect(EditField1.left,EditField1.top,EditField1.Width,
> E
> ditField1.Height)
>
> RefreshRect doesn't work as I would expect. I would assume that you
> would use the control's left, top, width and height settings, but for
> some reason, it doesn't work that way. I had to move the EditField
> into
> a position where the refresh was occurring. You might have to play
> around with the numbers. If the settings are not correct, the whole
> window will jitter with each refresh. Very annoying, but will probably
> only be noticeable on Windows. Also, if the EditField has the focus,
> the cursor will jitter apparently even if the RefreshRect settings are
> correct, on Windows, and probably Mac. You might get by with removing
> the focus from the EditField if it ever gets focus.
>
> Another side effect is that the user will not be able to type or copy
> the text in the EditField. If this isn't important, use a StaticText
> box instead of an EditField.
>
> I don't think Paint events are really intended for this sort of thing.
> Is using 4 lines of extra code in four different places, when you
> technically don't have to, that big of a deal? :)
>
> HTH and I hope I didn't misunderstand the situation.
>
> -----Original Message-----
> From: <email address removed>
> [mailto:<email address removed>] On Behalf Of
> Barrie Jones
> Sent: Tuesday, February 01, 2005 6:00 PM
> To: Getting Started
> Subject: Re: Update editField in a paint event
>
> Thank you Jack. "Number" is a parameter variable. I also tried it as a
> global variable and as a window property without success. "Number" is
> incrementing OK because it affects the graphics. It seems that the
> editfield is dead when it is in the graphics method. It is not a show
> stopper since it works OK outside the graphics method but this requires
> the code to be placed in four places.
> By the way, "number" increments each time other editfields get a
> keyDown event (four of them). The KeyDown event activates a canvas
> paint event with canvas1.refresh. A fifth editField displays "number"
> ----> myField.text = str(number) which works OK when myField.text > str(number) is placed in each of the four keyDown events but not when
> it is only placed in the paint event. It displays correctly on the
> first pass only but not on subsequent passes. myField.refresh does not
> help.
> I will try to replicate the problem with a simplified example as
> suggested by Joe. In the meantime, if anyone spots a clue in the above
> description, please let me know.
> Thanks
> Barrie
>
> On Feb 1, 2005, at 1:40 AM, CV wrote:
>
>> Hopefully, Number is not a local variable.
>>
>> In a simple project, with Number as Integer added as a window
>> property, it works fine for me:
>>
>> In Paint event:
>> self.Number = self.Number + 1
>> EditField1.text = str(self.Number)
>>
>> When I resize the window, the editfield displays the correct count.
>>
>> HTH,
>>
>> Jack
>>
>> On Jan 31, 2005, at 5:27 PM, Barrie Jones wrote:
>>
>>> Can someone please let me know if the following editField behavior is
>>> normal or possibly caused by my program.
>>> The setup:
>>> I have an EditField that should be updated each time a graphics
>>> operation is performed.
>>> The update code, myField.text = str(number) is in a graphics method
>>> called by the canvas paint event.
>>> "number" is incremented every time the paint event is fired.
>>> The problem:
>>> myField.text appears to update with the first pass, but remains the
>>> same after each subsequent pass through the paint event.
>>>
>>> The problem is fixed by placing myField.text = str(number) outside
>>> the paint event.
>>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives of this list here:
>> <http://www.realsoftware.com/listarchives/lists.html>
>>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://www.realsoftware.com/listarchives/lists.html>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://www.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>