Page 1 of 1

Hiliting / Un-Hiliting (D4D)

PostPosted: Mon May 06, 2019 3:22 pm
by dhs
I am experiencing problems with un-hiliting an entity in my current D4D project, and I am hoping Mark or Dave may be able to outline the correct usage of the D4D hiliting methods? I've outlined what I am currently doing below.

I'm using the code below to hilite an entity:
Code: Select all        hi_lite (true, l^.ent, true, true);

The entity is being hilited as expected.

I have tried various code to un-hilite the entity. My current logic is shown below (the unhilite_all and ssClear were added in desperation):
Code: Select all        hi_lite (false, l^.ent, false, true);
        unhilite_all (true, true, false);

The entity is un-hilited and drawn on the screen correctly with the above code. If I refresh the screen from the display list then it remains drawn correctly. BUT if I redraw the screen the hilite returns and I cannot get rid of it.

I have tried adding an unhlite_all call to the main menu of the macro (hopefully to un-hilite anything that is inadvertently left hilited when the macro returns to that menu), but that has no effect. I am not certain of the significance of the add and nolog parameters to the unhilite_all procedure, but I have tried various values with no effect.

I am using hi_lite in one or 2 other places in the macro and the un-hilite seems to work properly there, but I cannot see what I am doing differently in the above case. I am probably missing something basic, but any help would be appreciated.

David H.

Re: Hiliting / Un-Hiliting (D4D) ... Solved ?

PostPosted: Mon May 06, 2019 4:00 pm
by dhs
After posting the previous post I had a really close look at logic where the unhilite was working and compared it with logic where it was not working. Fortunately I had some extremely similar logic that I could compare.

Both sets of logic were calling procedures that did an ent_update on the previouly hilited entity. Both procedures were being called after the logic that was (attempting to) un-hiliting the entity in question.
The difference was that one procedure was doing an ent_get (ent, ent.addr) before working on ent, and the other procedure was simply working on ent that was in memory. The unhiliting logic was working for the procedure that did the ent_get, but it appears that updating the entity from memory was causing the problem with the un-hilite.

Adding an ent_get following the un-hilite has fixed the problem. The following is the code I am now using:
Code: Select all        unhilite_all (true, true, false);
        ent_get (l^.ent, l^.ent.addr);

I would still value clarification of the use of the unhilite_all parameters and the recommended way to un-hilite an entity. It appears that there is something stored in the entity record that impacts on the hiliting and that unhilite_all does not necessarily un-hilite all entities (at least not with the parameters I tried).

David H.