Android Question A date control which either provides i) a hyperlink ii) a hyperlink to a superscripted/subscripted count variable

beelze69

Active Member
Licensed User
Longtime User
Hi,

I want to show the date and the number of activities for that date in the form of a date control:

Is there any date control available which will show both the date and <another count number>

For example, the value can be shown 'in superscript/subscript' form to the day of the date in that control.

Further, if I click that subscript/superscript 'count' which represents the number of activities for that date, it will show a popup/textbox of all the activities for that date that are pending execution...

Any help will be useful.

Thanks
 

beelze69

Active Member
Licensed User
Longtime User
Hi Erel,

I made a copy of the XUI Views.b4XLib file as 'FormyDateControl.b4XLib'.. It is in my B4A\Libraries Folder.

But I don't understand how to open it in the b4A IDE..

Sorry if I sound too basic.

Please help.

Thanks.
 
Last edited:
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
Hi Erel,

Thanks , renamed and loaded the template bas file.

Some more doubts.

1) There is a Date method for setting the date which can be invoked with

DateTemplate.Date = DateTime.Now

But in the Template bas file there is no Date method written.

It is getDate and setDate..

So, where is the Date Method written to return the date ?

2) In the setDate method you have mentioned in the
comments

'The layout is not loaded immediately so we need to make sure
that the layout is loaded ..

Can you please explain this part ?

3) I want to create a small panel and display some content
when the end-user clicks on a particular day in the
date control.

Under which click event of the renamed b4xDateTemplate bas file should
I write it in ?

Thanks ..
 
Last edited:
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
But in the Template bas file there is no Date method written.

It is getDate and setDate..
The answer to this question is here in the Custom View guide.


2) if the caller loads a layout with a custom view, the view is not actually fully initialised when control is passed back to the caller.

so,
B4X:
p.loadlayout("Datecontrolayout")
datecontrol.date = datetime.now

if the setDate function attempted to update an element of the loaded view immediately, there would be an "object not initialised" error, hence the need to delay the update of the visual control, until it has been fully initialised.


3) Which events have you tried? What happens?
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
The answer to this question is here in the Custom View guide.


2) if the caller loads a layout with a custom view, the view is not actually fully initialised when control is passed back to the caller.

so,
B4X:
p.loadlayout("Datecontrolayout")
datecontrol.date = datetime.now

if the setDate function attempted to update an element of the loaded view immediately, there would be an "object not initialised" error, hence the need to delay the update of the visual control, until it has been fully initialised.


3) Which events have you tried? What happens?
Hi Andrew !

Thanks for responding to my query..

Pointwise,

1) Sorry ! I still did not understand .. I understood that 'get' and 'set' should be prefixed to certain words to define properties and that we can write our own properties. But in datecontrol.date , where is the 'date' method/property written ?

2) Okay .. Got it .

3) I have not tried any of the events... But I want to do the following:

I have a list of certain days for a month..

a) As the date control is drawn, only for those days in the list I want to draw some kind of hyperlink OR if possible those days will be in 'different colour' in the date control.

b) When the user will click on that day , it will show some panel with some information ...Now there is a 'btnYear_Click' event and a 'btnMonth_Click' event but I don't know as to 'which event will fire when i press the day in the control'... So...

Can you guide me as to how it should be done?

Thanks...
 
Last edited:
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
1) Sorry ! I still did not understand .. I understood that 'get' and 'set' should be prefixed to certain words to define properties and that we can write our own properties. But in datecontrol.date , where is the 'date' method/property written ?

Read page 21 again, lowercase setxxx gets transformed in to a on xxx, lowercase getxxx get transformed into a read on xxx, so setDate and getDate become read and write on Date. Add a new sub getReadMe and you will see that a new property appears, ReadMe which is Readonly.

3) I have not tried any of the events... But I want to do the following:

I have a list of certain days for a month..

a) As the date control is drawn, only for those days in the list I want to draw some kind of hyperlink OR if possible those days will be in 'different colour' in the date control.

b) When the user will click on that day , it will show some panel with some information ...Now there is a 'btnYear_Click' event and a 'btnMonth_Click' event but I don't know as to 'which event will fire when i press the day in the control'... So...

There are several ways to solve this which is why I asked what have you tried. You have full control over the drawing so drawing text with an underline as a hyperlink should be no problem.

I would imagine that you need to put something in DrawDays which checks if the day matches your list and instead of doing the DrawText as written, do whatever you require such as adding the underline, to simulate a hyperlink and changing the color.
B4X:
    For day = 1 To daysInMonth
        Dim row As Int = (day - 1 + dayOfWeekOffset) / 7
       'Do a check here
        cvs.DrawText(day, (((dayOfWeekOffset + day - 1) Mod 7) + 0.5) * boxW, _
            (row + 0.5)* boxH + vCorrection, daysFont, DaysInMonthColor , "CENTER")
    Next

If you put breakpoints on each of the click events you can see which one is fired and when.

Handle_mouse event deals with clicking on the days.
so you would need to do something around the -
B4X:
        cvsBackground.ClearRect(cvsBackground.TargetRect)
        If validDay Then
            SelectDay(newSelectedDay)
            Hide
        End If

I would imagine.

Experiment!

That's the joy of coding...
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
Hi Andrew !

I once again thank you for responding to my doubts.

Point-wise replies for my doubts on 1) and 3) above.

1) Thanks !... I got it now.... I simply did not connect the getDate and setDate to the 'Date' property and so never really understood what you were trying to convey.. I got it now....

3) Thanks for helping me get started on the events thing... As you said, I need to experiment...

Thank you very much.
 
Last edited:
Upvote 0
Top