It is currently Sun May 19, 2013 1:00 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Indicate change in text
PostPosted: Fri Mar 02, 2012 3:37 pm 
Offline
User
User

Joined: Mon Jun 23, 2008 11:09 am
Posts: 32
Location: Copenhagen
Dear All,

I have a programme that shows records in a couple of editor fields. The user can change the text in the fields.
What I would like to do is to signal to the user that he has changed the text by changing the background colour.

Just now I can think of two ways of doing it.
1. record content then use a timer that compares the recorded with the present content every 0.5s
2. record content then use EventGadget for the editorfields to indicate that something has happened, compare texts as above

However both seem to have their disadvantages:
1. seems like a waste of resources and will continue running even when the programme is in the background (this could be solved if there is a Window - lostfocus, but I can't find one)
2. this is evoked for any number of reasons, not all are related to changes in the text

Is there a smart(er) way of doing it?

all the best / Björn


Top
 Profile  
 
 Post subject: Re: Indicate change in text
PostPosted: Fri Mar 02, 2012 3:57 pm 
Offline
User
User

Joined: Mon Jul 09, 2007 4:47 pm
Posts: 67
Location: Right Here
Windows only:
EM_GETMODIFY


Top
 Profile  
 
 Post subject: Re: Indicate change in text
PostPosted: Fri Mar 02, 2012 4:01 pm 
Offline
User
User

Joined: Mon Jun 23, 2008 11:09 am
Posts: 32
Location: Copenhagen
Nice, but do you know anything about the reliability? At least someone seems to have had problems with it...

http://msdn.microsoft.com/en-us/library ... 92(v=vs.85).aspx


Top
 Profile  
 
 Post subject: Re: Indicate change in text
PostPosted: Fri Mar 02, 2012 4:48 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:51 pm
Posts: 2715
Location: Portugal, Lisbon
Code:
 Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = #String_minutes
        If EventType = #PB_EventType_Change ; <---- DING DING
          Do extra check to see if it is equal to last value
          etc....
        EndIf
      EndIf

_________________
Software: http://xipa.org
Elevator Maintenance: http://central-elevadores.pt
Good web hosting!


Top
 Profile  
 
 Post subject: Re: Indicate change in text
PostPosted: Fri Mar 02, 2012 4:48 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 1563
Location: Berlin, Germany
BjornF wrote:
[EventGadget] is evoked for any number of reasons, not all are related to changes in the text

Is there a smart(er) way of doing it?

I use #PB_Event_Gadget together with #PB_EventType_Change:
Code:
      event = WaitWindowEvent()

      If event = #PB_Event_Gadget
         Select EventGadget()
            Case #MyEditField
               Select EventType()
                  Case #PB_EventType_Change
                     ; do something
               EndSelect
            [...]

Works fine for me.

Regards, Little John

//edit: Num3 was some seconds faster. :-)

_________________
Math problems?
Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].


Top
 Profile  
 
 Post subject: Re: Indicate change in text
PostPosted: Fri Mar 02, 2012 4:53 pm 
Offline
User
User

Joined: Mon Jun 23, 2008 11:09 am
Posts: 32
Location: Copenhagen
Excellent ! :D

Thank you for the help, just the thing I was after. / Björn


edit: I just tried it, and couldn't get it to work :( :( :(
Did you try it? (Editorgadget isn't noted as one of the gadgets it can be used on)


Top
 Profile  
 
 Post subject: Re: Indicate change in text
PostPosted: Fri Mar 02, 2012 5:17 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:51 pm
Posts: 2715
Location: Portugal, Lisbon
BjornF wrote:
Excellent ! :D

Thank you for the help, just the thing I was after. / Björn


edit: I just tried it, and couldn't get it to work :( :( :(
Did you try it? (Editorgadget isn't noted as one of the gadgets it can be used on)


Upsss you forgot to mention it was for an editor gadget!

I don't think it will work with that :(

_________________
Software: http://xipa.org
Elevator Maintenance: http://central-elevadores.pt
Good web hosting!


Top
 Profile  
 
 Post subject: Re: Indicate change in text
PostPosted: Fri Mar 02, 2012 5:55 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 1563
Location: Berlin, Germany
Ooops ...

For an EditorGadget, use this code (slightly modified for recent PB versions after a code by srod):
Code:
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   EditorGadget(0, 8, 8, 306, 133)
   ;Add the following line to enable the editor gadget to send #EN_CHANGE notifications.
   SendMessage_(GadgetID(0), #EM_SETEVENTMASK, 0, SendMessage_(GadgetID(0), #EM_GETEVENTMASK, 0,0)|#ENM_CHANGE)
   
   For a = 0 To 5
      AddGadgetItem(0, a, "Line " + Str(a))
   Next
   
   Repeat
      Event = WaitWindowEvent()
      Select EventType()
         Case #PB_EventType_Change
            Debug "changed"
      EndSelect
   Until Event = #PB_Event_CloseWindow
EndIf

Regards, Little John

_________________
Math problems?
Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].


Top
 Profile  
 
 Post subject: Re: Indicate change in text
PostPosted: Fri Mar 02, 2012 6:02 pm 
Offline
User
User

Joined: Mon Jun 23, 2008 11:09 am
Posts: 32
Location: Copenhagen
Thank you, I'll have a go with that one. / all the best, Björn


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye