Wednesday, April 12, 2023

More bells and whistles for the 'Blog' program

In the course of retrieving the tag frequency counts for the 1600 blogs, I had some more ideas for improving the 'blog' program. The first (that I am not going to show here) appears in the 'choose entries' form: one now has the option of choosing tags either alphabetically or by frequency (this of course means that every now and then I have to recalculate the frequencies). I don't know whether this idea is going to be a keeper, but it definitely helped, at least for cataloguing this blog entry, as 'programming' and 'delphi' are in the top five tags.

The other idea took me by surprise. In the 'show entries' form that is fed by the above 'choose entries' form, I had previously added a popup menu with a few options and short cuts. Today I added another option; as one has to rely on one's memory in order to know which short cut does what, I thought that I would add the options to the screen's status bar.

Then I had a delicious thought: would it be possible to click on a pane in order to execute the appropriate command? I've never done this before so I did some Stack Overflow research and found this question. There are a couple of solutions given; I used the first method that uses the OnMouseDown event of the status bar. As this solution simply displays the pane number, I had to exend it in order to have the click execute something. At first I listed the various options in a case statement, but I wasn't very happy with this. Then it occurred to me that the panel index is the same as the popup menu index, so I could use this and save a case statement that was getting a bit awkward because the event handler had to exit if an option were chosen. My contribution below is the tmenuitem (popupmenu1.Items[i]).Click line. Maybe I can use this idea in the 'manager' program.

procedure TShowEntries.sbMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin tcomponent (sender).tag:= x; end; procedure TShowEntries.sbClick(Sender: TObject); var accwidth, i: integer; begin accwidth:= 0; for i:= 0 to sb.panels.count - 1 do begin accwidth:= accwidth + sb.panels[i].width; if sb.Tag < accwidth then begin tmenuitem (popupmenu1.Items[i]).Click; break end end; end;


This day in history:

Blog #Date TitleTags
82612/04/2015How not to display data in graphsStatistics
112112/04/2018Apology to Israel RailwaysTrains

No comments: