-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathB4JViewTimeDialog.b4j
More file actions
80 lines (75 loc) · 2.53 KB
/
B4JViewTimeDialog.b4j
File metadata and controls
80 lines (75 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
AppType=JavaFX
Build1=Default,b4j.example
File1=1.bjl
File2=CustomDialog.bjl
FileGroup1=Default Group
FileGroup2=Default Group
Group=Default Group
Library1=jcore
Library2=jfx
Library3=xui views
NumberOfFiles=2
NumberOfLibraries=3
NumberOfModules=0
Version=7
@EndOfDesignText@
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private dialog As B4XDialog
Private lblTime As Label
Private ftfHour As B4XFloatTextField
Private ftfMinute As B4XFloatTextField
Private cbAMPM As B4XComboBox
Dim HH As Int = 12
Dim MM As Int = 0
Dim TT As Int = 1
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
dialog.Initialize(MainForm.RootPane)
dialog.Title = "B4JViewTimeDialog"
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub MainForm_Resize (Width As Double, Height As Double)
If dialog.Visible Then dialog.Resize(Width, Height)
End Sub
Sub lblTime_MouseClicked (EventData As MouseEvent)
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 300dip, 150dip)
p.LoadLayout("CustomDialog")
ftfHour.TextField.EditTextHint = "12"
ftfMinute.TextField.EditTextHint = "00"
cbAMPM.SetItems(Array As String("AM", "PM"))
cbAMPM.SelectedIndex = TT
dialog.PutAtTop = True 'put the dialog at the top of the screen
'dialog.BackgroundColor = fx.Colors.ARGB(200, 125, 125, 125)
'dialog.ButtonsColor = fx.Colors.RGB(125, 125, 125)
If HH < 10 Then ftfHour.Text = "0" & HH Else ftfHour.Text = HH
If MM < 10 Then ftfMinute.Text = "0" & MM Else ftfMinute.Text = MM
Dim rs As ResumableSub = dialog.ShowCustom(p, "OK", "", "CANCEL")
ftfHour.TextField.RequestFocus
Wait For (rs) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
If ftfHour.Text = "" Or ftfHour.Text = "0" Or ftfHour.Text = "00" Then HH = 12 Else HH = ftfHour.Text
If ftfMinute.Text = "" Then MM = 0 Else MM = ftfMinute.Text
If HH > 12 Then HH = 12
If MM > 59 Then MM = 0
If HH < 10 Then ftfHour.Text = "0" & HH Else ftfHour.Text = HH
If MM < 10 Then ftfMinute.Text = "0" & MM Else ftfMinute.Text = MM
TT = cbAMPM.SelectedIndex
Dim strValue As String = ftfHour.Text & ":" & ftfMinute.Text & " " & cbAMPM.GetItem(cbAMPM.SelectedIndex)
'dialog.Show(strValue, "OK", "", "")
lblTime.Text = strValue
End If
End Sub