B4J Question Ignore SelectedChange True at first runtime cycle [SOLVED]

Discussion in 'B4J Questions' started by ThRuST, Jul 4, 2019.

  1. ThRuST

    ThRuST Well-Known Member Licensed User

    Since I am implementing sound themes to events, the sound is played automatically once the application runs - if SelectedChange is set to True.

    Sound is played each time it is changed. Any clever advice how to prevent sound to play at first runtime cycle?

    EDIT I've made an example that illustrates the problem.

    Note that state.dat is saved to drive D:\ in v1.0

    v1.0 is the first example that doesn't have any Bool checking.
    v1.1 implements bool check but the sound does not play at first click (when state is Disabled)
    v1.2 I finally nailed it, it works yay :)

    Attached Files:

    Last edited: Jul 4, 2019
  2. Mashiane

    Mashiane Expert Licensed User

    Private bLoading As Boolean
    Sub Initialize
    bLoading = 

    blah blah blah
    blah blah blah.

    bLoading = 
    End Sub
    Sub SelectChange
    if bLoading = True then Return
  3. ThRuST

    ThRuST Well-Known Member Licensed User

    Ok I see your point, but I've allready a step ahead even though I didn't mention it initiallity :)

    This is a mess, but you'll get the idea what I am trying to achieve. It works (almost) except that sound is never played the first time the button toggles from false to true, in that case the selection is turned off. So this makes it slightly more complicated, so I need to think about this some more. Perhaps a Boolean will be enough? The storestate is a boolean to save my confusion state :)

    Private StoreState1 As Boolean = Selected
    If TempStopSound = 0 Then
            TempStopSound = TempStopSound + 
    'restore state
            BtnFilterSQL.Selected = StoreState1
    End If

    'If BtnFilterSQL.Selected = False Then
            'TempStopSound = TempStopSound + 1
    '        Return
    'End If
    If TempStopSound >=1 Then
            TempStopSound = 
    If Selected = True Then
    else if Selected = False Then
    Log ("Tempstopsound main sub : " & TempStopSound)
    End If
    End If

  4. Mashiane

    Mashiane Expert Licensed User

    Tip: I have learned the hard way never to set variable assignments in Process / Class Globals unless they are constants.

    I will check this stuff out...
  5. ThRuST

    ThRuST Well-Known Member Licensed User

    I'll put together a source code example to illustrate the problem. Here's the two sound files I generated in case you want to try it yourself.

    And of course it uses a ToggleButton

    Attached Files:

  6. ThRuST

    ThRuST Well-Known Member Licensed User

    Ok, I've made an example. SelectionChange v1.0 Drop it like it's hot :cool:

    Oh and I almost forgot.. Switch to Enabled state and restart the program.
    She's talking, when she shouldn't. Any programmer teach her a lesson ASAP :D
  7. ThRuST

    ThRuST Well-Known Member Licensed User

    btw what values do you get from running the source code v1.0? Here's what I got (Release mode)

  8. ThRuST

    ThRuST Well-Known Member Licensed User

    It's done, download v1.2 and behold the poetry in motion... :cool:
  9. ThRuST

    ThRuST Well-Known Member Licensed User

    @Mashiane I have now successfully implemented the structure into my project Athena and it works as expected.

    All together now : say YAY, say Hooh, Say YAY, Say Hooh :)
  10. ThRuST

    ThRuST Well-Known Member Licensed User

    Advice for anyone who will use the SelectedChange solution in v1.2. My advice is to set ToggleButton.Tag = "Enabled" or "Disabled" directly after the selection value has been loaded. This way you can use a materialize icon on the button instead of depend on text. I learned this from a tutorial by Erel, and it works extremely well :)

    Here's my own solution to this

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice