petter@lulea.telesoft.se (Petter Bengtsson) (04/23/91)
InterViews 3.0 beta, Sun4, Sun C++ v2.0 When running the `Namer' dialog box example (p9-23 of "Ibuild User's Guide"), the text entered in the StringEditor is printed twice. Why is Namer::entered() called twice? Has anyone else experienced this behavior? ====================================================================== Petter Bengtsson, TeleSoft Telecom AB, Lulea, Sweden Email: petter@lulea.telesoft.se ======================================================================
grahamd@otc.otca.oz.au (Graham Dumpleton) (04/25/91)
In article <3650@lulea.telesoft.se>, petter@lulea.telesoft.se (Petter Bengtsson) writes: |> InterViews 3.0 beta, Sun4, Sun C++ v2.0 |> |> When running the `Namer' dialog box example (p9-23 of |> "Ibuild User's Guide"), the text entered in the StringEditor |> is printed twice. |> |> Why is Namer::entered() called twice? |> |> Has anyone else experienced this behavior? |> Yes. What is happening is that the event handler (entered()) is being called on each change in the value of the button state, i.e 1->0 as well as 0->1. Use the following code and things are okay. void Namer::entered() { int value = 0; enterBS->GetValue(value); if (value) { cout << stringEditor->Text() << endl; enterBS->SetValue(0); } } This will ensure that something is only done on 0->1 transition. I presumed it was an oversight in the guide. -- Graham Dumpleton (grahamd@otc.otca.oz.au)