B4J Question [SOLVED] _FocusChanged event for controls in CLV does not fire when ASTabMenu clicked - in Linux Only

cjpryor

Active Member
Licensed User
Any ideas about how to best handle this situation?

I am running Ubuntu 20.04.2 LTS with open jdk 14.0.1. I have the same version of Java on all of my development machines (Windows, Mac, and Linux).

I have several fields (as a B4XViews) embedded in a CLV that do not fire the _FocusChanged event when focus is lost when I click on an ASTabMenu button. Any other loss of focus fires the _FocusChanged event. This only happens on my Linux computer. This issue does not occur on Windows and Mac. The behavior is the same when deployed as when in debug mode over B4J Bridge so I can clearly see where it is failing.

I tried to work around it by calling the _FocusChanged events for the fields in question in the ASTabMenu_TabClick event (see sample code below) but that blows up because the context for the original _LostFocus event is lost. I suppose I could capture the context as an instance of the last field entered in the CLV and then use that in this special case ... maybe.

Here are some relevant code excerpts for one example of one of the CLV Fields.

B4X:
Private Sub TextAreaNote_FocusChanged (HasFocus As Boolean)
    
    'Log("Notes Text Focus Changed: HasFocus = [" & HasFocus & "]")
    
    If (HasFocus) Then
        
        'reset flag
        blnNotesTextChanged=False
        
    Else if blnNotesTextChanged Then
        
        'Log("Write new text value to database = [" & newNotesText & "]")
        
        Dim noteField As B4XView = Sender
        'Log("noteField Tag: " & noteField.Tag)
        
        //Blows up here when called from ASTabMenu1_TabClick
        Dim noteFieldTag As Map = noteField.Tag 

...

    End If
    
End Sub

...

Private Sub ASTabMenu1_TabClick(index As Int)
    
    'if os is linux call all of the lost focus events
    
    If MainPage.operatingSystem="linux" Then
        
        TextField_Decimal_FocusChanged(False)
        TextAreaNote_FocusChanged(False)
        TextField_Date_FocusChanged(False)
        
    End If
    
    ...
    
End Sub
 

cjpryor

Active Member
Licensed User
I forgot to mention, I get the same behavior with open jdk 11.0.1. I wonder if I need to try Java 8 for Linux only deployments.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
ASTabMenu is using the normal _MouseClicked (EventData As MouseEvent) Event.

Theoretically you can test it with a normal panel, if you log the event there to see if the other events still work.
 
Upvote 0

cjpryor

Active Member
Licensed User
FYI, same result with JDK 8.

@Alexander Stolte Thank you for the suggestion. The issue is that the TextAreaNote_FocusChanged event is not firing when the ASTabMenu1 is clicked after changing the value in the TextAreaNote field. The ASTabMenu1_TabClick event fires just fine so I was hoping I could make up for the TextAreaNote_FocusChanged event not firing in the ASTabMenu1_TabClick event. However, at least with my initial simplistic attempt, the context I need in the TextAreaNote_FocusChanged event is lost when calling it from the ASTabMenu1_TabClick event.

I hope that makes sense.

Thanks
 
Last edited:
Upvote 0

cjpryor

Active Member
Licensed User
I suppose, for Linux only, I could add a save button in the CLV row for the fields that do not fire the FocusChanged event and instruct users to always click that button. It does not really have to do anything since the FocusChanged event will fire as long as the button is in the CLV.
 
Upvote 0

cjpryor

Active Member
Licensed User
I think, for Linux only, I will grab the context I need in the _TextChanged events and then use that if the FocusChanged event doesn't fire before the ASTabMenu clicked event fires ...
 
Last edited:
Upvote 0

Similar Threads

Top